-
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.
fetch latest version from github repo
- Loading branch information
Showing
2 changed files
with
38 additions
and
18 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,19 +1,13 @@ | ||
export async function getLatestVersion() { | ||
try { | ||
const latestVersion = "0.1.0"; | ||
console.log(latestVersion); | ||
return latestVersion; | ||
} catch (error) { | ||
console.error(`Error while retrieving the latest version. No release found.\n ${error}`); | ||
} | ||
} | ||
import { SlashCommandBuilder } from 'discord.js'; | ||
import { checkVersion } from '../../utils.js'; | ||
|
||
export const data = new SlashCommandBuilder().setName('version').setDescription('Display version info'); | ||
|
||
export async function execute(interaction) { | ||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const currentVersion = '0.1.0'; | ||
const version = await checkVersion(currentVersion); | ||
|
||
export function checkVersion(currentVersion) { | ||
getLatestVersion().then((latestVersion) => { | ||
if (currentVersion < latestVersion) { | ||
console.log(`A new update is available: ${latestVersion}`); | ||
} else { | ||
console.log(`You have the latest version of the code.`); | ||
} | ||
}); | ||
await interaction.followUp({ content: version, 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