-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import { SlashCommandBuilder } from 'discord.js'; | ||
import { checkVersion } from '../../utils.js'; | ||
import { getLatestVersion } from '../../utils.js'; | ||
|
||
export const data = new SlashCommandBuilder().setName('version').setDescription('Display version info'); | ||
const VERSION = '0.0.1'; | ||
|
||
export const data = new SlashCommandBuilder().setName('version').setDescription('Display version info').addBooleanOption((option) => option.setName('check').setDescription('Check for update').setRequired(false)); | ||
|
||
export async function execute(interaction) { | ||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const currentVersion = '0.1.0'; | ||
const version = await checkVersion(currentVersion); | ||
const current = VERSION; | ||
|
||
let reply = `You already have the latest version (${current}).`; | ||
|
||
const { options } = interaction; | ||
|
||
await interaction.followUp({ content: version, ephemeral: true }); | ||
const check = options.getBoolean('check'); | ||
if (check) { | ||
console.log('Checking for updates...') | ||
const latest = await getLatestVersion(); | ||
if (current < latest) { | ||
reply = `The latest version is ${latest}. You are using version ${current}.`; | ||
} | ||
} | ||
else { | ||
console.log('Not checking for updates') | ||
} | ||
await interaction.followUp({ content: reply, ephemeral: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters