diff --git a/locales/en/bot.json b/locales/en/bot.json index fa782b9..5d296a0 100644 --- a/locales/en/bot.json +++ b/locales/en/bot.json @@ -3,19 +3,227 @@ "trackName": "{{title}} [Author: {{author}}]" }, "commands": { + "back": { + "metadata": { + "name": "back", + "description": "Go back to previous track or specified position in history.", + "options": { + "position": { + "name": "position", + "description": "The position in history to go back to." + } + } + } + }, + "filters": { + "metadata": { + "name": "filters", + "description": "Toggle various audio filters.", + "options": { + "type": { + "name": "type", + "description": "Audio filter type to use." + } + } + } + }, + "guilds": { + "metadata": { + "name": "guilds", + "description": "Show the top 25 guilds by member count." + } + }, + "help": { + "metadata": { + "name": "help", + "description": "Show the list of bot commands." + }, + "listTitle": "{{icon}} **List of commands**", + "supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}", + "addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**" + }, + "history": { + "metadata": { + "name": "history", + "description": "Show history of tracks that have been played.", + "options": { + "page": { + "name": "page", + "description": "Page number to display for the history." + } + } + } + }, + "join": { + "metadata": { + "name": "join", + "description": "The bot will join the voice channel if not already in one." + } + }, + "leave": { + "metadata": { + "name": "leave", + "description": "Clear the queue and remove bot from voice channel." + } + }, + "loop": { + "metadata": { + "name": "loop", + "description": "Toggle looping a track, the whole queue or autoplay.", + "options": { + "mode": { + "name": "mode", + "description": "Loop mode: Track, queue, autoplay or disabled." + } + } + } + }, "lyrics": { "metadata": { - "description": "Search Genius lyrics for current or specified track. TEST", "name": "lyrics", + "description": "Search Genius lyrics for current or specified track.", "options": { "query": { "name": "query", - "description": "Search query by text or URL. TEST" + "description": "Search query by text or URL." } } }, "autocompleteSearchResult": "{{title}} [Artist: {{artist}}]" }, - "help": {} + "move": { + "metadata": { + "name": "move", + "description": "Move a track to a specified position in queue.", + "options": { + "from": { + "name": "from", + "description": "The position of the track to move." + }, + "to": { + "name": "to", + "description": "The position to move the track to." + } + } + } + }, + "nowplaying": { + "metadata": { + "name": "nowplaying", + "description": "Show information about the current track." + } + }, + "pause": { + "metadata": { + "name": "pause", + "description": "Toggle pause for the current track." + } + }, + "play": { + "metadata": { + "name": "play", + "description": "Add a track or playlist to the queue by search query or URL.", + "options": { + "query": { + "name": "query", + "description": "Search query by text or URL." + } + } + } + }, + "queue": { + "metadata": { + "name": "queue", + "description": "Show tracks that have been added to the queue.", + "options": { + "page": { + "name": "page", + "description": "Page number to display for the queue." + } + } + } + }, + "reload": { + "metadata": { + "name": "reload", + "description": "Reload slash command, autocomplete and component interactions across shards." + } + }, + "seek": { + "metadata": { + "name": "seek", + "description": "Seek to a position in the current track.", + "options": { + "duration": { + "name": "duration", + "description": "Duration in format 00:00:00 (HH:mm:ss)." + } + } + } + }, + "shards": { + "metadata": { + "name": "shards", + "description": "Show information about all connected shards.", + "options": { + "sort": { + "name": "sort", + "description": "What to sort the shards by." + }, + "page": { + "name": "page", + "description": "Page number to display for the shards." + } + } + } + }, + "shuffle": { + "metadata": { + "name": "shuffle", + "description": "Randomly shuffle all tracks in the queue." + } + }, + "skip": { + "metadata": { + "name": "skip", + "description": "Skip track to next or specified position in queue.", + "options": { + "position": { + "name": "position", + "description": "The position in queue to skip to." + } + } + } + }, + "status": { + "metadata": { + "name": "status", + "description": "Show operational status of the bot." + } + }, + "stop": { + "metadata": { + "name": "stop", + "description": "Clear the queue and stop playing audio." + } + }, + "systemstatus": { + "metadata": { + "name": "systemstatus", + "description": "Show operational status of the bot with additional technical information." + } + }, + "volume": { + "metadata": { + "name": "volume", + "description": "Show or change the playback volume for tracks.", + "options": { + "percentage": { + "name": "percentage", + "description": "Volume percentage: From 1% to 100%." + } + } + } + } } } diff --git a/locales/resources.d.ts b/locales/resources.d.ts index 686768a..09893b1 100644 --- a/locales/resources.d.ts +++ b/locales/resources.d.ts @@ -4,20 +4,228 @@ interface Resources { "trackName": "{{title}} [Author: {{author}}]" }, "commands": { + "back": { + "metadata": { + "name": "back", + "description": "Go back to previous track or specified position in history.", + "options": { + "position": { + "name": "position", + "description": "The position in history to go back to." + } + } + } + }, + "filters": { + "metadata": { + "name": "filters", + "description": "Toggle various audio filters.", + "options": { + "type": { + "name": "type", + "description": "Audio filter type to use." + } + } + } + }, + "guilds": { + "metadata": { + "name": "guilds", + "description": "Show the top 25 guilds by member count." + } + }, + "help": { + "metadata": { + "name": "help", + "description": "Show the list of bot commands." + }, + "listTitle": "{{icon}} **List of commands**", + "supportServerCallout": "{{icon}} **Support server**\nJoin the support server for help or to suggest improvements:\n{{invite}}", + "addBotCallout": "{{icon}} **Enjoying {{botName}}?**\nAdd me to another server:\n**[Click me!]({{invite}})**" + }, + "history": { + "metadata": { + "name": "history", + "description": "Show history of tracks that have been played.", + "options": { + "page": { + "name": "page", + "description": "Page number to display for the history." + } + } + } + }, + "join": { + "metadata": { + "name": "join", + "description": "The bot will join the voice channel if not already in one." + } + }, + "leave": { + "metadata": { + "name": "leave", + "description": "Clear the queue and remove bot from voice channel." + } + }, + "loop": { + "metadata": { + "name": "loop", + "description": "Toggle looping a track, the whole queue or autoplay.", + "options": { + "mode": { + "name": "mode", + "description": "Loop mode: Track, queue, autoplay or disabled." + } + } + } + }, "lyrics": { "metadata": { - "description": "Search Genius lyrics for current or specified track. TEST", "name": "lyrics", + "description": "Search Genius lyrics for current or specified track.", "options": { "query": { "name": "query", - "description": "Search query by text or URL. TEST" + "description": "Search query by text or URL." } } }, "autocompleteSearchResult": "{{title}} [Artist: {{artist}}]" }, - "help": {} + "move": { + "metadata": { + "name": "move", + "description": "Move a track to a specified position in queue.", + "options": { + "from": { + "name": "from", + "description": "The position of the track to move." + }, + "to": { + "name": "to", + "description": "The position to move the track to." + } + } + } + }, + "nowplaying": { + "metadata": { + "name": "nowplaying", + "description": "Show information about the current track." + } + }, + "pause": { + "metadata": { + "name": "pause", + "description": "Toggle pause for the current track." + } + }, + "play": { + "metadata": { + "name": "play", + "description": "Add a track or playlist to the queue by search query or URL.", + "options": { + "query": { + "name": "query", + "description": "Search query by text or URL." + } + } + } + }, + "queue": { + "metadata": { + "name": "queue", + "description": "Show tracks that have been added to the queue.", + "options": { + "page": { + "name": "page", + "description": "Page number to display for the queue." + } + } + } + }, + "reload": { + "metadata": { + "name": "reload", + "description": "Reload slash command, autocomplete and component interactions across shards." + } + }, + "seek": { + "metadata": { + "name": "seek", + "description": "Seek to a position in the current track.", + "options": { + "duration": { + "name": "duration", + "description": "Duration in format 00:00:00 (HH:mm:ss)." + } + } + } + }, + "shards": { + "metadata": { + "name": "shards", + "description": "Show information about all connected shards.", + "options": { + "sort": { + "name": "sort", + "description": "What to sort the shards by." + }, + "page": { + "name": "page", + "description": "Page number to display for the shards." + } + } + } + }, + "shuffle": { + "metadata": { + "name": "shuffle", + "description": "Randomly shuffle all tracks in the queue." + } + }, + "skip": { + "metadata": { + "name": "skip", + "description": "Skip track to next or specified position in queue.", + "options": { + "position": { + "name": "position", + "description": "The position in queue to skip to." + } + } + } + }, + "status": { + "metadata": { + "name": "status", + "description": "Show operational status of the bot." + } + }, + "stop": { + "metadata": { + "name": "stop", + "description": "Clear the queue and stop playing audio." + } + }, + "systemstatus": { + "metadata": { + "name": "systemstatus", + "description": "Show operational status of the bot with additional technical information." + } + }, + "volume": { + "metadata": { + "name": "volume", + "description": "Show or change the playback volume for tracks.", + "options": { + "percentage": { + "name": "percentage", + "description": "Volume percentage: From 1% to 100%." + } + } + } + } } } } diff --git a/package.json b/package.json index 009039a..b68746e 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,13 @@ "build": "tsc", "toc": "i18next-resources-for-ts interface -i ./locales/en -o ./locales/resources.d.ts" }, + "nodemonConfig": { + "ignore": [ + "src/**", + "logs/**" + ], + "execMap": {} + }, "dependencies": { "@discord-player/extractor": "^4.4.5", "@discord-player/opus": "^0.1.2", diff --git a/src/common/localeUtil.ts b/src/common/localeUtil.ts index dbf03a4..c73a18c 100644 --- a/src/common/localeUtil.ts +++ b/src/common/localeUtil.ts @@ -74,7 +74,7 @@ export function localizeCommand(command: Omit 0) { assert(englishData.options, `Command /${command.name} must have option localizations.`); for (const unwritableOption of jsonCommand.options) { const option = unwritableOption as never as APIApplicationCommandOption; diff --git a/src/interactions/commands/info/help.ts b/src/interactions/commands/info/help.ts index 8e4c521..5495cce 100644 --- a/src/interactions/commands/info/help.ts +++ b/src/interactions/commands/info/help.ts @@ -7,22 +7,25 @@ import { } from 'discord.js'; import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; +import { localizeCommand, useServerTranslator } from '../../../common/localeUtil'; import { ExtendedClient } from '../../../types/clientTypes'; +import { TFunction } from 'i18next'; class HelpCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder().setName('help').setDescription('Show the list of bot commands.'); + const data = localizeCommand(new SlashCommandBuilder().setName('help')); super(data); } async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType { const { executionId, client, interaction } = params; const logger = this.getLogger(this.name, executionId, interaction); + const translator = useServerTranslator(interaction); const [commandEmbedString, supportServerString, addBotString] = await Promise.all([ this.getCommandEmbedString(client!), - this.getSupportServerString(), - this.getAddBotString() + this.getSupportServerString(translator), + this.getAddBotString(translator) ]); logger.debug('Responding with info embed.'); @@ -30,7 +33,10 @@ class HelpCommand extends BaseSlashCommandInteraction { embeds: [ new EmbedBuilder() .setDescription( - `${this.embedOptions.icons.rule} **List of commands**\n` + + translator('commands.help.listTitle', { + icon: this.embedOptions.icons.rule + }) + + '\n' + commandEmbedString + supportServerString + addBotString @@ -77,32 +83,27 @@ class HelpCommand extends BaseSlashCommandInteraction { return ''; } - private async getSupportServerString(): Promise { + private async getSupportServerString(translator: TFunction): Promise { if (!this.botOptions.serverInviteUrl) { return ''; } - const embedString = ` - ${this.embedOptions.icons.support} **Support server** - Join the support server for help or to suggest improvements: - **${this.botOptions.serverInviteUrl}** - `; - - return embedString; + return translator('commands.help.supportServerCallout', { + icon: this.embedOptions.icons.support, + invite: this.botOptions.serverInviteUrl + }); } - private async getAddBotString(): Promise { + private async getAddBotString(translator: TFunction): Promise { if (!this.botOptions.botInviteUrl) { return ''; } - const embedString = ` - ${this.embedOptions.icons.bot} **Enjoying ${this.botOptions.name}?** - Add me to another server: - **[Click me!](${this.botOptions.botInviteUrl})** - `; - - return embedString; + return translator('commands.help.addBotCallout', { + icon: this.embedOptions.icons.bot, + botName: this.botOptions.name, + invite: this.botOptions.botInviteUrl + }); } } diff --git a/src/interactions/commands/info/status.ts b/src/interactions/commands/info/status.ts index b56e4f7..eb7e340 100644 --- a/src/interactions/commands/info/status.ts +++ b/src/interactions/commands/info/status.ts @@ -4,10 +4,11 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; +import { localizeCommand } from '../../../common/localeUtil'; class StatusCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder().setName('status').setDescription('Show operational status of the bot.'); + const data = localizeCommand(new SlashCommandBuilder().setName('status')); super(data); } diff --git a/src/interactions/commands/player/back.ts b/src/interactions/commands/player/back.ts index 4eec50a..b06f41c 100644 --- a/src/interactions/commands/player/back.ts +++ b/src/interactions/commands/player/back.ts @@ -5,15 +5,15 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkHistoryExists, checkQueueCurrentTrack } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class BackCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('back') - .setDescription('Go back to previous track or specified position in history.') - .addIntegerOption((option) => - option.setName('position').setDescription('The position in history to go back to.').setMinValue(1) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('back') + .addIntegerOption((option) => option.setName('position').setMinValue(1)) + ); super(data); } diff --git a/src/interactions/commands/player/filters.ts b/src/interactions/commands/player/filters.ts index 97f4278..91cc4db 100644 --- a/src/interactions/commands/player/filters.ts +++ b/src/interactions/commands/player/filters.ts @@ -26,6 +26,7 @@ import { import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions'); const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions'); @@ -33,21 +34,21 @@ const equalizerFilterOptions: EqualizerFilterOptions = config.get('equalizerFilt class FiltersCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('filters') - .setDescription('Toggle various audio filters.') - .addStringOption((option) => - option - .setName('type') - .setDescription('Audio filter type to use.') - .setRequired(false) - .addChoices( - { name: 'FFmpeg', value: 'ffmpeg' }, - { name: 'Biquad', value: 'biquad' }, - { name: 'Equalizer', value: 'equalizer' }, - { name: 'Disable', value: 'disable' } - ) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('filters') + .addStringOption((option) => + option + .setName('type') + .setRequired(false) + .addChoices( + { name: 'FFmpeg', value: 'ffmpeg' }, + { name: 'Biquad', value: 'biquad' }, + { name: 'Equalizer', value: 'equalizer' }, + { name: 'Disable', value: 'disable' } + ) + ) + ); super(data); } diff --git a/src/interactions/commands/player/history.ts b/src/interactions/commands/player/history.ts index d049917..ef62acc 100644 --- a/src/interactions/commands/player/history.ts +++ b/src/interactions/commands/player/history.ts @@ -16,15 +16,15 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkHistoryExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class HistoryCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('history') - .setDescription('Show history of tracks that have been played.') - .addIntegerOption((option) => - option.setName('page').setDescription('Page number to display for the history').setMinValue(1) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('history') + .addIntegerOption((option) => option.setName('page').setMinValue(1)) + ); super(data); } diff --git a/src/interactions/commands/player/join.ts b/src/interactions/commands/player/join.ts index be02147..981787b 100644 --- a/src/interactions/commands/player/join.ts +++ b/src/interactions/commands/player/join.ts @@ -5,12 +5,11 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class JoinCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('join') - .setDescription('The bot will join the voice channel if not already in one.'); + const data = localizeCommand(new SlashCommandBuilder().setName('join')); super(data); } diff --git a/src/interactions/commands/player/leave.ts b/src/interactions/commands/player/leave.ts index 6cd9b68..daed2c0 100644 --- a/src/interactions/commands/player/leave.ts +++ b/src/interactions/commands/player/leave.ts @@ -4,12 +4,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class LeaveCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('leave') - .setDescription('Clear the queue and remove bot from voice channel.'); + const data = localizeCommand(new SlashCommandBuilder().setName('leave')); super(data); } diff --git a/src/interactions/commands/player/loop.ts b/src/interactions/commands/player/loop.ts index 5ce0b14..2403d22 100644 --- a/src/interactions/commands/player/loop.ts +++ b/src/interactions/commands/player/loop.ts @@ -11,24 +11,26 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class LoopCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('loop') - .setDescription('Toggle looping a track, the whole queue or autoplay.') - .addIntegerOption(() => - new SlashCommandIntegerOption() - .setName('mode') - .setDescription('Loop mode: Track, queue, autoplay or disabled.') - .setRequired(false) - .addChoices( - { name: 'Track', value: QueueRepeatMode.TRACK }, - { name: 'Queue', value: QueueRepeatMode.QUEUE }, - { name: 'Autoplay', value: QueueRepeatMode.AUTOPLAY }, - { name: 'Disabled', value: QueueRepeatMode.OFF } - ) - ); + // TODO: Add choice localization support + const data = localizeCommand( + new SlashCommandBuilder() + .setName('loop') + .addIntegerOption(() => + new SlashCommandIntegerOption() + .setName('mode') + .setRequired(false) + .addChoices( + { name: 'Track', value: QueueRepeatMode.TRACK }, + { name: 'Queue', value: QueueRepeatMode.QUEUE }, + { name: 'Autoplay', value: QueueRepeatMode.AUTOPLAY }, + { name: 'Disabled', value: QueueRepeatMode.OFF } + ) + ) + ); super(data); } diff --git a/src/interactions/commands/player/lyrics.ts b/src/interactions/commands/player/lyrics.ts index 4c67b36..3e1d25a 100644 --- a/src/interactions/commands/player/lyrics.ts +++ b/src/interactions/commands/player/lyrics.ts @@ -13,15 +13,8 @@ class LyricsCommand extends BaseSlashCommandInteraction { const data = localizeCommand( new SlashCommandBuilder() .setName('lyrics') - // .setDescription('Search Genius lyrics for current or specified track.') .addStringOption((option) => - option - .setName('query') - // .setDescription('Search query by text or URL.') - .setRequired(false) - .setMinLength(2) - .setMaxLength(500) - .setAutocomplete(true) + option.setName('query').setRequired(false).setMinLength(2).setMaxLength(500).setAutocomplete(true) ) ); super(data); diff --git a/src/interactions/commands/player/move.ts b/src/interactions/commands/player/move.ts index 0f95017..50d2378 100644 --- a/src/interactions/commands/player/move.ts +++ b/src/interactions/commands/player/move.ts @@ -5,26 +5,16 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class MoveCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('move') - .setDescription('Move a track to a specified position in queue.') - .addIntegerOption((option) => - option - .setName('from') - .setDescription('The position of the track to move') - .setMinValue(1) - .setRequired(true) - ) - .addIntegerOption((option) => - option - .setName('to') - .setDescription('The position to move the track to') - .setMinValue(1) - .setRequired(true) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('move') + .addIntegerOption((option) => option.setName('from').setMinValue(1).setRequired(true)) + .addIntegerOption((option) => option.setName('to').setMinValue(1).setRequired(true)) + ); super(data); } diff --git a/src/interactions/commands/player/nowplaying.ts b/src/interactions/commands/player/nowplaying.ts index 8b7ab2a..7a5f992 100644 --- a/src/interactions/commands/player/nowplaying.ts +++ b/src/interactions/commands/player/nowplaying.ts @@ -14,12 +14,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes'; import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class NowPlayingCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('nowplaying') - .setDescription('Show information about the current track.'); + const data = localizeCommand(new SlashCommandBuilder().setName('nowplaying')); super(data); } diff --git a/src/interactions/commands/player/pause.ts b/src/interactions/commands/player/pause.ts index 6eed373..b711052 100644 --- a/src/interactions/commands/player/pause.ts +++ b/src/interactions/commands/player/pause.ts @@ -5,10 +5,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class PauseCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.'); + const data = localizeCommand(new SlashCommandBuilder().setName('pause')); super(data); } diff --git a/src/interactions/commands/player/play.ts b/src/interactions/commands/player/play.ts index e51c21c..6c349c2 100644 --- a/src/interactions/commands/player/play.ts +++ b/src/interactions/commands/player/play.ts @@ -6,21 +6,17 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator'; import { transformQuery } from '../../../utils/validation/searchQueryValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class PlayCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('play') - .setDescription('Add a track or playlist to the queue by search query or URL.') - .addStringOption((option) => - option - .setName('query') - .setDescription('Search query by text or URL') - .setRequired(true) - .setMinLength(2) - .setMaxLength(500) - .setAutocomplete(true) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('play') + .addStringOption((option) => + option.setName('query').setRequired(true).setMinLength(2).setMaxLength(500).setAutocomplete(true) + ) + ); super(data); } diff --git a/src/interactions/commands/player/queue.ts b/src/interactions/commands/player/queue.ts index 97e8595..79131c8 100644 --- a/src/interactions/commands/player/queue.ts +++ b/src/interactions/commands/player/queue.ts @@ -17,15 +17,15 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { formatDuration } from '../../../common/formattingUtils'; +import { localizeCommand } from '../../../common/localeUtil'; class QueueCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('queue') - .setDescription('Show tracks that have been added to the queue.') - .addIntegerOption((option) => - option.setName('page').setDescription('Page number to display for the queue').setMinValue(1) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('queue') + .addIntegerOption((option) => option.setName('page').setMinValue(1)) + ); super(data); } diff --git a/src/interactions/commands/player/remove.ts b/src/interactions/commands/player/remove.ts index 7e454b7..2a22a21 100644 --- a/src/interactions/commands/player/remove.ts +++ b/src/interactions/commands/player/remove.ts @@ -8,6 +8,7 @@ import { Logger } from 'pino'; class RemoveCommand extends BaseSlashCommandInteraction { constructor() { + // TODO: Add subcommand localization support const data = new SlashCommandBuilder() .setName('remove') .setDescription('Remove tracks from the queue') diff --git a/src/interactions/commands/player/seek.ts b/src/interactions/commands/player/seek.ts index 53c1fd3..c5970d6 100644 --- a/src/interactions/commands/player/seek.ts +++ b/src/interactions/commands/player/seek.ts @@ -5,15 +5,15 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class SeekCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('seek') - .setDescription('Seek to a duration in the current track.') - .addStringOption((option) => - option.setName('duration').setDescription('Duration in format 00:00:00 (HH:mm:ss).').setRequired(true) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('seek') + .addStringOption((option) => option.setName('duration').setRequired(true)) + ); super(data); } diff --git a/src/interactions/commands/player/shuffle.ts b/src/interactions/commands/player/shuffle.ts index 2b2713f..0630f4a 100644 --- a/src/interactions/commands/player/shuffle.ts +++ b/src/interactions/commands/player/shuffle.ts @@ -4,12 +4,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueEmpty, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class ShuffleCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('shuffle') - .setDescription('Randomly shuffle all tracks in the queue.'); + const data = localizeCommand(new SlashCommandBuilder().setName('shuffle')); super(data); } diff --git a/src/interactions/commands/player/skip.ts b/src/interactions/commands/player/skip.ts index 11adf5d..6c1be6e 100644 --- a/src/interactions/commands/player/skip.ts +++ b/src/interactions/commands/player/skip.ts @@ -5,15 +5,15 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class SkipCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('skip') - .setDescription('Skip track to next or specified position in queue.') - .addIntegerOption((option) => - option.setName('position').setDescription('The position in queue to skip to.').setMinValue(1) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('skip') + .addIntegerOption((option) => option.setName('position').setMinValue(1)) + ); super(data); } diff --git a/src/interactions/commands/player/stop.ts b/src/interactions/commands/player/stop.ts index ac1c04d..ec5b9ee 100644 --- a/src/interactions/commands/player/stop.ts +++ b/src/interactions/commands/player/stop.ts @@ -4,12 +4,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class StopCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('stop') - .setDescription('Clear the queue and stop playing audio.'); + const data = localizeCommand(new SlashCommandBuilder().setName('stop')); super(data); } diff --git a/src/interactions/commands/player/volume.ts b/src/interactions/commands/player/volume.ts index e1df671..77e50e3 100644 --- a/src/interactions/commands/player/volume.ts +++ b/src/interactions/commands/player/volume.ts @@ -5,19 +5,15 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../typ import { checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class VolumeCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('volume') - .setDescription('Show or change the playback volume for tracks.') - .addIntegerOption((option) => - option - .setName('percentage') - .setDescription('Volume percentage: From 1% to 100%.') - .setMinValue(0) - .setMaxValue(100) - ); + const data = localizeCommand( + new SlashCommandBuilder() + .setName('volume') + .addIntegerOption((option) => option.setName('percentage').setMinValue(0).setMaxValue(100)) + ); super(data); } diff --git a/src/interactions/commands/system/guilds.ts b/src/interactions/commands/system/guilds.ts index 9512a9f..4f98aca 100644 --- a/src/interactions/commands/system/guilds.ts +++ b/src/interactions/commands/system/guilds.ts @@ -4,12 +4,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { ExtendedClient } from '../../../types/clientTypes'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class GuildsCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('guilds') - .setDescription('Show the top 25 guilds by member count.'); + const data = localizeCommand(new SlashCommandBuilder().setName('guilds')); const isSystemCommand: boolean = true; super(data, isSystemCommand); } diff --git a/src/interactions/commands/system/reload.ts b/src/interactions/commands/system/reload.ts index 3b947d9..07ad150 100644 --- a/src/interactions/commands/system/reload.ts +++ b/src/interactions/commands/system/reload.ts @@ -10,12 +10,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { ExtendedClient } from '../../../types/clientTypes'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class ReloadCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('reload') - .setDescription('Reload slash command, autocomplete and component interactions across shards.'); + const data = localizeCommand(new SlashCommandBuilder().setName('reload')); const isSystemCommand: boolean = true; super(data, isSystemCommand); } diff --git a/src/interactions/commands/system/shards.ts b/src/interactions/commands/system/shards.ts index 5bbd180..2ad2460 100644 --- a/src/interactions/commands/system/shards.ts +++ b/src/interactions/commands/system/shards.ts @@ -10,30 +10,30 @@ import { ExtendedClient } from '../../../types/clientTypes'; import { BaseSlashCommandParams, BaseSlashCommandReturnType, ShardInfo } from '../../../types/interactionTypes'; import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator'; import { Logger } from 'pino'; +import { localizeCommand } from '../../../common/localeUtil'; class ShardsCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('shards') - .setDescription('Show information about all connected shards.') - .addStringOption((option) => - option - .setName('sort') - .setDescription('What to sort the shards by.') - .setRequired(false) - .addChoices( - { name: 'None (Shard ID)', value: 'none' }, - { name: 'Memory usage', value: 'memory' }, - { name: 'Voice Connections', value: 'connections' }, - { name: 'Tracks', value: 'tracks' }, - { name: 'Listeners', value: 'listeners' }, - { name: 'Guilds', value: 'guilds' }, - { name: 'Members', value: 'members' } - ) - ) - .addIntegerOption((option) => - option.setName('page').setDescription('Page number to display for the shards').setMinValue(1) - ); + // TODO: Localize choices + const data = localizeCommand( + new SlashCommandBuilder() + .setName('shards') + .addStringOption((option) => + option + .setName('sort') + .setRequired(false) + .addChoices( + { name: 'None (Shard ID)', value: 'none' }, + { name: 'Memory usage', value: 'memory' }, + { name: 'Voice Connections', value: 'connections' }, + { name: 'Tracks', value: 'tracks' }, + { name: 'Listeners', value: 'listeners' }, + { name: 'Guilds', value: 'guilds' }, + { name: 'Members', value: 'members' } + ) + ) + .addIntegerOption((option) => option.setName('page').setMinValue(1)) + ); const isSystemCommand: boolean = true; super(data, isSystemCommand); } diff --git a/src/interactions/commands/system/systemstatus.ts b/src/interactions/commands/system/systemstatus.ts index d9277b9..60322ca 100644 --- a/src/interactions/commands/system/systemstatus.ts +++ b/src/interactions/commands/system/systemstatus.ts @@ -5,12 +5,11 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../../common/statusUtils'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator'; +import { localizeCommand } from '../../../common/localeUtil'; class SystemStatusCommand extends BaseSlashCommandInteraction { constructor() { - const data = new SlashCommandBuilder() - .setName('systemstatus') - .setDescription('Show operational status of the bot with additional technical information.'); + const data = localizeCommand(new SlashCommandBuilder().setName('systemstatus')); const isSystemCommand: boolean = true; super(data, isSystemCommand); }