Transcribe command descriptions and call localize

This commit is contained in:
tacheometry committed 2023-12-15 14:42:36 +02:00
1 parent 46d1cfb008
commit 2cfab3209b
28 files changed
+578 -181

No files matched your search

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