diff --git a/config/default.js b/config/default.js index a76933d..97e21a0 100644 --- a/config/default.js +++ b/config/default.js @@ -89,6 +89,7 @@ module.exports.embedOptions = { nextTrack: '⏭️', previousTrack: '⏮️', pauseResumeTrack: '⏯️', + paused: '⏸', shuffleQueue: '🔀', loop: '🔁', loopAction: '🔁', diff --git a/locales/en/bot.json b/locales/en/bot.json index d6912ff..cd9f013 100644 --- a/locales/en/bot.json +++ b/locales/en/bot.json @@ -26,7 +26,13 @@ "options": { "type": { "name": "type", - "description": "Audio filter type to use." + "description": "Audio filter type to use.", + "choices": { + "ffmpeg": "FFmpeg", + "biquad": "Biquad", + "equalizer": "Equalizer", + "disable": "Disable" + } } } }, @@ -93,7 +99,13 @@ "options": { "mode": { "name": "mode", - "description": "Loop mode: Track, queue, autoplay or disabled." + "description": "Loop mode: Track, queue, autoplay or disabled.", + "choices": { + "0": "Off", + "1": "Track", + "2": "Queue", + "3": "Autoplay" + } } } }, @@ -102,13 +114,7 @@ "modeChanged": "{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.", "willAutoplay": "When the queue is empty, similar tracks will start playing!", "willNoLongerPlay": "The {{mode}} will no longer play on repeat!", - "willNowPlay": "The {{mode}} will now play on repeat!", - "repeatMode": { - "off": "disabled", - "track": "track", - "queue": "queue", - "autoplay": "autoplay" - } + "willNowPlay": "The {{mode}} will now play on repeat!" }, "lyrics": { "metadata": { @@ -148,7 +154,16 @@ "metadata": { "name": "nowplaying", "description": "Show information about the current track." - } + }, + "embedFields": { + "author": "**Artist**", + "plays": "**Plays**", + "source": "**Track source**" + }, + "otherTracksInQueue_one": "1 other track in the queue...", + "otherTracksInQueue": "{{count}} other tracks in the queue...", + "playCount_zero": "Unknown", + "playCount": "{{count, number}}" }, "pause": { "metadata": { @@ -156,7 +171,8 @@ "description": "Toggle pause for the current track." }, "pauseConfirmation": "{{icon}} **Paused track**", - "resumeConfirmation": "{{icon}} **Resumed track**" + "resumeConfirmation": "{{icon}} **Resumed track**", + "directSource": "Direct source" }, "play": { "metadata": { @@ -227,7 +243,16 @@ "options": { "sort": { "name": "sort", - "description": "What to sort the shards by." + "description": "What to sort the shards by.", + "choices": { + "none": "None (Shard ID)", + "memory": "Memory usage", + "connections": "Voice Connections", + "tracks": "Tracks", + "listeners": "Listeners", + "guilds": "Guilds", + "members": "Members" + } }, "page": { "name": "page", @@ -306,13 +331,22 @@ "footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)", "footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)", "loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.", + "nowPausedTitle": "{{icon}} **Currently paused**", "nowPlayingTitle": "{{icon}} **Now playing**", "playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.", + "queueRepeatMode": { + "off": "Disabled", + "track": "Track", + "queue": "Queue", + "autoplay": "Autoplay" + }, "requestedBy": "**Requested by:** {{user}}", + "unavailableAuthor": "Unavailable", "unavailableDuration": "_No duration available._", "unavailableRequestedBy": "Unavailable", "unavailableTrackTitle": "Title unavailable", "unavailableTrackUrl": "**Unavailable**", + "unavailableSource": "Unavailable", "voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)" }, "statistics": { diff --git a/locales/resources.d.ts b/locales/resources.d.ts index 6b3122b..d25b7b7 100644 --- a/locales/resources.d.ts +++ b/locales/resources.d.ts @@ -27,7 +27,13 @@ interface Resources { "options": { "type": { "name": "type", - "description": "Audio filter type to use." + "description": "Audio filter type to use.", + "choices": { + "ffmpeg": "FFmpeg", + "biquad": "Biquad", + "equalizer": "Equalizer", + "disable": "Disable" + } } } }, @@ -94,7 +100,13 @@ interface Resources { "options": { "mode": { "name": "mode", - "description": "Loop mode: Track, queue, autoplay or disabled." + "description": "Loop mode: Track, queue, autoplay or disabled.", + "choices": { + "0": "Off", + "1": "Track", + "2": "Queue", + "3": "Autoplay" + } } } }, @@ -103,13 +115,7 @@ interface Resources { "modeChanged": "{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.", "willAutoplay": "When the queue is empty, similar tracks will start playing!", "willNoLongerPlay": "The {{mode}} will no longer play on repeat!", - "willNowPlay": "The {{mode}} will now play on repeat!", - "repeatMode": { - "off": "disabled", - "track": "track", - "queue": "queue", - "autoplay": "autoplay" - } + "willNowPlay": "The {{mode}} will now play on repeat!" }, "lyrics": { "metadata": { @@ -149,7 +155,16 @@ interface Resources { "metadata": { "name": "nowplaying", "description": "Show information about the current track." - } + }, + "embedFields": { + "author": "**Artist**", + "plays": "**Plays**", + "source": "**Track source**" + }, + "otherTracksInQueue_one": "1 other track in the queue...", + "otherTracksInQueue": "{{count}} other tracks in the queue...", + "playCount_zero": "Unknown", + "playCount": "{{count, number}}" }, "pause": { "metadata": { @@ -157,7 +172,8 @@ interface Resources { "description": "Toggle pause for the current track." }, "pauseConfirmation": "{{icon}} **Paused track**", - "resumeConfirmation": "{{icon}} **Resumed track**" + "resumeConfirmation": "{{icon}} **Resumed track**", + "directSource": "Direct source" }, "play": { "metadata": { @@ -228,7 +244,16 @@ interface Resources { "options": { "sort": { "name": "sort", - "description": "What to sort the shards by." + "description": "What to sort the shards by.", + "choices": { + "none": "None (Shard ID)", + "memory": "Memory usage", + "connections": "Voice Connections", + "tracks": "Tracks", + "listeners": "Listeners", + "guilds": "Guilds", + "members": "Members" + } }, "page": { "name": "page", @@ -307,13 +332,22 @@ interface Resources { "footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)", "footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)", "loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.", + "nowPausedTitle": "{{icon}} **Currently paused**", "nowPlayingTitle": "{{icon}} **Now playing**", "playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.", + "queueRepeatMode": { + "off": "Disabled", + "track": "Track", + "queue": "Queue", + "autoplay": "Autoplay" + }, "requestedBy": "**Requested by:** {{user}}", + "unavailableAuthor": "Unavailable", "unavailableDuration": "_No duration available._", "unavailableRequestedBy": "Unavailable", "unavailableTrackTitle": "Title unavailable", "unavailableTrackUrl": "**Unavailable**", + "unavailableSource": "Unavailable", "voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)" }, "statistics": { diff --git a/src/classes/interactions.ts b/src/classes/interactions.ts index a3fee14..b169a1c 100644 --- a/src/classes/interactions.ts +++ b/src/classes/interactions.ts @@ -27,7 +27,6 @@ import { } from '../types/interactionTypes'; import { Validator, ValidatorParams } from '../types/utilTypes'; import { TFunction } from 'i18next'; -import { formatSlashCommand } from '../common/formattingUtils'; abstract class BaseInteraction { embedOptions: EmbedOptions; @@ -162,34 +161,6 @@ abstract class BaseInteraction { return progressBar; } - protected getDisplayRepeatMode(repeatMode: number, translator: TFunction, state: string = 'info'): string { - let loopModeUserString: string; - let icon: string; - - switch (repeatMode) { - case 1: - loopModeUserString = 'track'; - icon = state === 'info' ? this.embedOptions.icons.loop : this.embedOptions.icons.looping; - break; - case 2: - loopModeUserString = 'queue'; - icon = state === 'info' ? this.embedOptions.icons.loop : this.embedOptions.icons.looping; - break; - case 3: - loopModeUserString = 'autoplay'; - icon = state === 'info' ? this.embedOptions.icons.autoplay : this.embedOptions.icons.autoplaying; - break; - default: - return ''; - } - - return translator('musicPlayerCommon.loopingInfo', { - icon, - loopMode: loopModeUserString, - loopCommand: formatSlashCommand('loop', translator) - }); - } - abstract execute( params: BaseInteractionParams ): Promise | ApplicationCommandOptionChoiceData | void>; diff --git a/src/common/formattingUtils.ts b/src/common/formattingUtils.ts index e9f7104..7dad160 100644 --- a/src/common/formattingUtils.ts +++ b/src/common/formattingUtils.ts @@ -1,4 +1,6 @@ +import { QueueRepeatMode } from 'discord-player'; import { TFunction } from 'i18next'; +import { EmbedOptions } from '../types/configTypes'; export function formatDuration(durationMs: number): string { const durationDate: Date = new Date(0); @@ -26,3 +28,45 @@ export function formatSlashCommand(commandName: string, translator: TFunction): }); return `**\`/${translatedName}\`**`; } + +export function formatRepeatMode(repeatMode: QueueRepeatMode, translator: TFunction): string { + switch (repeatMode) { + case QueueRepeatMode.AUTOPLAY: + return translator('musicPlayerCommon.queueRepeatMode.autoplay'); + case QueueRepeatMode.OFF: + return translator('musicPlayerCommon.queueRepeatMode.off'); + case QueueRepeatMode.TRACK: + return translator('musicPlayerCommon.queueRepeatMode.track'); + case QueueRepeatMode.QUEUE: + return translator('musicPlayerCommon.queueRepeatMode.queue'); + } +} + +export function formatRepeatModeDetailed( + repeatMode: QueueRepeatMode, + embedOptions: EmbedOptions, + translator: TFunction, + state: string = 'info' +) { + let icon: string; + + switch (repeatMode) { + case QueueRepeatMode.TRACK: + icon = state === 'info' ? embedOptions.icons.loop : embedOptions.icons.looping; + break; + case QueueRepeatMode.QUEUE: + icon = state === 'info' ? embedOptions.icons.loop : embedOptions.icons.looping; + break; + case QueueRepeatMode.AUTOPLAY: + icon = state === 'info' ? embedOptions.icons.autoplay : embedOptions.icons.autoplaying; + break; + default: + return ''; + } + + return translator('musicPlayerCommon.loopingInfo', { + icon, + loopMode: formatRepeatMode(repeatMode, translator), + loopCommand: formatSlashCommand('loop', translator) + }); +} diff --git a/src/common/localeUtil.ts b/src/common/localeUtil.ts index 3c3b35c..fc77c81 100644 --- a/src/common/localeUtil.ts +++ b/src/common/localeUtil.ts @@ -1,5 +1,11 @@ import assert from 'assert'; -import { APIApplicationCommandOption, BaseInteraction, Locale, SlashCommandBuilder } from 'discord.js'; +import { + APIApplicationCommandOption, + ApplicationCommandOptionType, + BaseInteraction, + Locale, + SlashCommandBuilder +} from 'discord.js'; import { lstatSync, readdirSync } from 'fs'; import i18n from 'i18next'; import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend'; @@ -20,6 +26,9 @@ translatorInstance.use(i18nextFsBackend).init({ backend: { loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'), addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json') + }, + interpolation: { + escapeValue: false } }); @@ -41,6 +50,7 @@ type CommandMetadata = { { name?: string; description?: string; + choices?: Record; } >; }; @@ -85,6 +95,29 @@ export function localizeCommand(command: Omit { - const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator); + const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator); logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`); logger.debug('Responding with warning embed.'); return await interaction.editReply({ @@ -127,7 +127,7 @@ class LoopCommand extends BaseSlashCommandInteraction { toRepeatMode: QueueRepeatMode, translator: TFunction ): Promise { - const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator); + const newRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator); const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply( fromRepeatMode, toRepeatMode, @@ -148,24 +148,13 @@ class LoopCommand extends BaseSlashCommandInteraction { }); } - private getRepeatModeEmbedName(repeatMode: QueueRepeatMode, translator: TFunction): string { - const repeatModeEmbedString: { [key in QueueRepeatMode]: string } = { - [QueueRepeatMode.OFF]: translator('commands.loop.repeatMode.off'), - [QueueRepeatMode.TRACK]: translator('commands.loop.repeatMode.track'), - [QueueRepeatMode.QUEUE]: translator('commands.loop.repeatMode.queue'), - [QueueRepeatMode.AUTOPLAY]: translator('commands.loop.repeatMode.autoplay') - }; - - return repeatModeEmbedString[repeatMode]; - } - private getChangedRepeatModeEmbedReply( fromRepeatMode: QueueRepeatMode, toRepeatMode: QueueRepeatMode, translator: TFunction ): string { - const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode, translator); - const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator); + const fromRepeatModeEmbedName = formatRepeatMode(fromRepeatMode, translator); + const toRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator); let repeatModeIcon = this.embedOptions.icons.looping; let newRepeatModeMessage: string = translator('commands.loop.willNowPlay', { diff --git a/src/interactions/commands/player/nowplaying.ts b/src/interactions/commands/player/nowplaying.ts index fa86953..900b931 100644 --- a/src/interactions/commands/player/nowplaying.ts +++ b/src/interactions/commands/player/nowplaying.ts @@ -15,6 +15,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } fro import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator'; import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator'; import { localizeCommand, useServerTranslator } from '../../../common/localeUtil'; +import { TFunction } from 'i18next'; +import { formatRepeatModeDetailed } from '../../../common/formattingUtils'; class NowPlayingCommand extends BaseSlashCommandInteraction { constructor() { @@ -40,8 +42,12 @@ class NowPlayingCommand extends BaseSlashCommandInteraction { const currentTrack: Track = queue.currentTrack!; const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator); const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator); - const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue); - const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue); + const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue, translator); + const displayQueueRepeatMode: string = formatRepeatModeDetailed( + queue.repeatMode, + this.embedOptions, + translator + ); const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator); const components: APIMessageActionRowComponent[] = []; @@ -69,9 +75,11 @@ class NowPlayingCommand extends BaseSlashCommandInteraction { components.push(skipButton); if (this.embedOptions.components.showButtonLabels) { - previousButton.label = 'Previous'; - playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause'; - skipButton.label = 'Skip'; + previousButton.label = translator('musicPlayerCommon.controls.previous'); + playPauseButton.label = queue.node.isPaused() + ? translator('musicPlayerCommon.controls.resume') + : translator('musicPlayerCommon.controls.pause'); + skipButton.label = translator('musicPlayerCommon.controls.skip'); } const embedActionRow: APIActionRowComponent = { @@ -87,13 +95,17 @@ class NowPlayingCommand extends BaseSlashCommandInteraction { .setDescription( `${displayTrackPlayingStatus}\n` + `${displayTrackUrl}\n` + - `**Requested by:** ${displayTrackRequestedBy}\n` + + `${translator('musicPlayerCommon.requestedBy', { + user: displayTrackRequestedBy + })}\n` + `${displayEmbedProgressBar}\n\n ` + `${displayQueueRepeatMode}\n\n` ) - .addFields(this.getEmbedFields(currentTrack)) + .addFields(this.getEmbedFields(currentTrack, translator)) .setFooter({ - text: tracksInQueueCount ? `${tracksInQueueCount} other tracks in the queue...` : ' ' + text: tracksInQueueCount + ? translator('commands.nowplaying.otherTracksInQueue', { count: tracksInQueueCount }) + : ' ' }) .setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!)) .setColor(this.embedOptions.colors.info) @@ -102,37 +114,34 @@ class NowPlayingCommand extends BaseSlashCommandInteraction { }); } - private getDisplayPlays(currentTrack: Track | undefined): string { + private getDisplayPlays(currentTrack: Track | undefined, translator: TFunction): string { const trackMetadata = currentTrack?.metadata as TrackMetadata; - let displayPlays: string = - (currentTrack?.views || trackMetadata?.bridge?.views || 0).toLocaleString('en-US') ?? '0'; - - if (displayPlays === '0') { - displayPlays = 'Unavailable'; - } - - return displayPlays; + return translator('commands.nowplaying.playCount', { + count: currentTrack?.views || trackMetadata?.bridge?.views || 0 + }); } - private getDisplayTrackAuthor(currentTrack: Track | undefined): string { - let author: string = currentTrack?.author ? currentTrack.author : 'Unavailable'; - if (author === 'cdn.discordapp.com') { - author = 'Unavailable'; + private getDisplayTrackAuthor(currentTrack: Track | undefined, translator: TFunction): string { + let author = currentTrack?.author; + if (!author || author === 'cdn.discordapp.com') { + author = translator('musicPlayerCommon.unavailableAuthor'); } return author; } - private getTrackSourceString(currentTrack: Track): string { + private getTrackSourceString(currentTrack: Track, translator: TFunction): string { const sourceStringsFormatted: Map = new Map([ ['youtube', 'YouTube'], ['soundcloud', 'SoundCloud'], ['spotify', 'Spotify'], ['apple_music', 'Apple Music'], - ['arbitrary', 'Direct source'] + ['arbitrary', translator('commands.pause.directSource')] ]); - return sourceStringsFormatted.get(currentTrack.raw.source!) ?? 'Unavailable'; + return ( + sourceStringsFormatted.get(currentTrack.raw.source!) ?? translator('musicPlayerCommon.unavailableSource') + ); } private getTrackSourceIcon(currentTrack: Track): string { @@ -147,59 +156,38 @@ class NowPlayingCommand extends BaseSlashCommandInteraction { return sourceIcons.get(currentTrack.raw.source!) ?? ''; } - private getDisplayTrackSource(currentTrack: Track) { - const trackSource: string = this.getTrackSourceString(currentTrack) ?? 'Unavailable'; + private getDisplayTrackSource(currentTrack: Track, translator: TFunction) { + const trackSource: string = this.getTrackSourceString(currentTrack, translator); const trackSourceIcon: string = this.getTrackSourceIcon(currentTrack) ?? ''; return `**${trackSourceIcon} [${trackSource}](${currentTrack.raw.url ?? currentTrack.url})**`; } - private getRepeatModeString(repeatMode: number): string { - const loopModesFormatted: Map = new Map([ - [0, 'disabled'], - [1, 'track'], - [2, 'queue'], - [3, 'autoplay'] - ]); - - return loopModesFormatted.get(repeatMode)!; - } - - private getDisplayQueueRepeatMode = (queue: GuildQueue): string => { - const repeatMode: number = queue.repeatMode; - if (repeatMode === 0) { - return ''; - } - - const loopModeUserString: string = this.getRepeatModeString(repeatMode); - const icon = repeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop; - return ( - `**${icon} Looping**\n` + - `Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.` - ); - }; - - private getDisplayTrackPlayingStatus = (queue: GuildQueue): string => { + private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => { return queue.node.isPaused() - ? '**Currently Paused**' - : `**${this.embedOptions.icons.audioPlaying} Now Playing**`; + ? translator('musicPlayerCommon.nowPausedTitle', { + icon: this.embedOptions.icons.paused + }) + : translator('musicPlayerCommon.nowPlayingTitle', { + icon: this.embedOptions.icons.audioPlaying + }); }; - private getEmbedFields = (currentTrack: Track): EmbedField[] => { + private getEmbedFields = (currentTrack: Track, translator: TFunction): EmbedField[] => { const fields: EmbedField[] = [ { - name: '**Author**', - value: this.getDisplayTrackAuthor(currentTrack), + name: translator('commands.nowplaying.embedFields.author'), + value: this.getDisplayTrackAuthor(currentTrack, translator), inline: true }, { - name: '**Plays**', - value: this.getDisplayPlays(currentTrack), + name: translator('commands.nowplaying.embedFields.plays'), + value: this.getDisplayPlays(currentTrack, translator), inline: true }, { - name: '**Track source**', - value: this.getDisplayTrackSource(currentTrack), + name: translator('commands.nowplaying.embedFields.source'), + value: this.getDisplayTrackSource(currentTrack, translator), inline: true } ]; diff --git a/src/interactions/commands/player/queue.ts b/src/interactions/commands/player/queue.ts index b957f6c..0e48dc7 100644 --- a/src/interactions/commands/player/queue.ts +++ b/src/interactions/commands/player/queue.ts @@ -16,7 +16,7 @@ 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 { formatDuration } from '../../../common/formattingUtils'; +import { formatDuration, formatRepeatModeDetailed } from '../../../common/formattingUtils'; import { localizeCommand, useServerTranslator } from '../../../common/localeUtil'; import { TFunction } from 'i18next'; @@ -123,20 +123,18 @@ class QueueCommand extends BaseSlashCommandInteraction { translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying }) + + '\n' + this.getFormattedTrackUrl(currentTrack, translator) + '\n' + translator('musicPlayerCommon.requestedBy', { user: this.getDisplayTrackRequestedBy(currentTrack, translator) }) + '\n' + - this.getDisplayQueueProgressBar(queue, translator) + - '\n' + - '\n' + - this.getDisplayRepeatMode(queue.repeatMode, translator) + - translator('commands.queue.tracksInQueueTitle', { + `${this.getDisplayQueueProgressBar(queue, translator)}\n\n` + + `${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}\n` + + `${translator('commands.queue.tracksInQueueTitle', { icon: this.embedOptions.icons.queue - }) + - '\n' + + })}\n` + queueTracksListString ) .setThumbnail(this.getTrackThumbnailUrl(currentTrack)) @@ -163,8 +161,10 @@ class QueueCommand extends BaseSlashCommandInteraction { new EmbedBuilder() .setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator)) .setDescription( - `${this.getDisplayRepeatMode(queue.repeatMode, translator)}` + - `**${this.embedOptions.icons.queue} Tracks in queue**\n` + + `${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}` + + `${translator('commands.queue.tracksInQueueTitle', { + icon: this.embedOptions.icons.queue + })}\n` + queueTracksListString ) .setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator)) diff --git a/src/interactions/commands/player/stop.ts b/src/interactions/commands/player/stop.ts index 09299db..621aacb 100644 --- a/src/interactions/commands/player/stop.ts +++ b/src/interactions/commands/player/stop.ts @@ -1,4 +1,4 @@ -import { GuildQueue, useQueue } from 'discord-player'; +import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player'; import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; import { BaseSlashCommandInteraction } from '../../../classes/interactions'; import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes'; @@ -27,7 +27,7 @@ class StopCommand extends BaseSlashCommandInteraction { ]); if (!queue.deleted) { - queue.setRepeatMode(0); + queue.setRepeatMode(QueueRepeatMode.OFF); queue.clear(); queue.node.stop(); logger.debug('Cleared and stopped the queue.'); diff --git a/src/interactions/commands/system/shards.ts b/src/interactions/commands/system/shards.ts index 2ad2460..3b83f0b 100644 --- a/src/interactions/commands/system/shards.ts +++ b/src/interactions/commands/system/shards.ts @@ -14,7 +14,6 @@ import { localizeCommand } from '../../../common/localeUtil'; class ShardsCommand extends BaseSlashCommandInteraction { constructor() { - // TODO: Localize choices const data = localizeCommand( new SlashCommandBuilder() .setName('shards') @@ -23,13 +22,13 @@ class ShardsCommand extends BaseSlashCommandInteraction { .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' } + { value: 'none', name: ' ' }, + { value: 'memory', name: ' ' }, + { value: 'connections', name: ' ' }, + { value: 'tracks', name: ' ' }, + { value: 'listeners', name: ' ' }, + { value: 'guilds', name: ' ' }, + { value: 'members', name: ' ' } ) ) .addIntegerOption((option) => option.setName('page').setMinValue(1)) diff --git a/src/interactions/components/action-pauseresume-button.ts b/src/interactions/components/action-pauseresume-button.ts index ebfa1b4..61d7a4f 100644 --- a/src/interactions/components/action-pauseresume-button.ts +++ b/src/interactions/components/action-pauseresume-button.ts @@ -6,6 +6,7 @@ import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator'; import { TFunction } from 'i18next'; import { useServerTranslator } from '../../common/localeUtil'; +import { formatRepeatModeDetailed } from '../../common/formattingUtils'; class ActionPauseResumeButton extends BaseComponentInteraction { constructor() { @@ -85,7 +86,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction { `**${this.embedOptions.icons.pauseResumed} ${ queue.node.isPaused() ? 'Paused Track' : 'Resumed track' }**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` + - `${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}` + `${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}` ) .setThumbnail(track.thumbnail) .setColor(this.embedOptions.colors.success); diff --git a/src/interactions/components/action-skip-button.ts b/src/interactions/components/action-skip-button.ts index c307869..5f822aa 100644 --- a/src/interactions/components/action-skip-button.ts +++ b/src/interactions/components/action-skip-button.ts @@ -6,6 +6,7 @@ import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator'; import { TFunction } from 'i18next'; import { useServerTranslator } from '../../common/localeUtil'; +import { formatRepeatModeDetailed } from '../../common/formattingUtils'; class ActionSkipButton extends BaseComponentInteraction { constructor() { @@ -79,7 +80,7 @@ class ActionSkipButton extends BaseComponentInteraction { .setDescription( `**${this.embedOptions.icons.skipped} Skipped track**\n` + `${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` + - `${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}` + `${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}` ) .setThumbnail(skippedTrack.thumbnail) .setColor(this.embedOptions.colors.success); diff --git a/src/types/configTypes.d.ts b/src/types/configTypes.d.ts index f93cf9e..b36d1d5 100644 --- a/src/types/configTypes.d.ts +++ b/src/types/configTypes.d.ts @@ -63,6 +63,7 @@ export type EmbedOptions = { nextTrack: string; previousTrack: string; pauseResumeTrack: string; + paused: string; shuffleQueue: string; loop: string; loopAction: string;