mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
Choice locallization support and finalize other commands
This commit is contained in:
16 files changed
+277
-179
No files matched your search
@@ -89,6 +89,7 @@ module.exports.embedOptions = {
|
|||||||
nextTrack: '⏭️',
|
nextTrack: '⏭️',
|
||||||
previousTrack: '⏮️',
|
previousTrack: '⏮️',
|
||||||
pauseResumeTrack: '⏯️',
|
pauseResumeTrack: '⏯️',
|
||||||
|
paused: '⏸',
|
||||||
shuffleQueue: '🔀',
|
shuffleQueue: '🔀',
|
||||||
loop: '🔁',
|
loop: '🔁',
|
||||||
loopAction: '🔁',
|
loopAction: '🔁',
|
||||||
|
|||||||
+46
-12
@@ -26,7 +26,13 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"type": {
|
"type": {
|
||||||
"name": "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": {
|
"options": {
|
||||||
"mode": {
|
"mode": {
|
||||||
"name": "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}}`**.",
|
"modeChanged": "{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.",
|
||||||
"willAutoplay": "When the queue is empty, similar tracks will start playing!",
|
"willAutoplay": "When the queue is empty, similar tracks will start playing!",
|
||||||
"willNoLongerPlay": "The {{mode}} will no longer play on repeat!",
|
"willNoLongerPlay": "The {{mode}} will no longer play on repeat!",
|
||||||
"willNowPlay": "The {{mode}} will now play on repeat!",
|
"willNowPlay": "The {{mode}} will now play on repeat!"
|
||||||
"repeatMode": {
|
|
||||||
"off": "disabled",
|
|
||||||
"track": "track",
|
|
||||||
"queue": "queue",
|
|
||||||
"autoplay": "autoplay"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"lyrics": {
|
"lyrics": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -148,7 +154,16 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "nowplaying",
|
"name": "nowplaying",
|
||||||
"description": "Show information about the current track."
|
"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": {
|
"pause": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -156,7 +171,8 @@
|
|||||||
"description": "Toggle pause for the current track."
|
"description": "Toggle pause for the current track."
|
||||||
},
|
},
|
||||||
"pauseConfirmation": "{{icon}} **Paused track**",
|
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||||
"resumeConfirmation": "{{icon}} **Resumed track**"
|
"resumeConfirmation": "{{icon}} **Resumed track**",
|
||||||
|
"directSource": "Direct source"
|
||||||
},
|
},
|
||||||
"play": {
|
"play": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -227,7 +243,16 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"sort": {
|
"sort": {
|
||||||
"name": "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": {
|
"page": {
|
||||||
"name": "page",
|
"name": "page",
|
||||||
@@ -306,13 +331,22 @@
|
|||||||
"footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)",
|
"footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)",
|
||||||
"footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)",
|
"footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)",
|
||||||
"loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.",
|
"loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.",
|
||||||
|
"nowPausedTitle": "{{icon}} **Currently paused**",
|
||||||
"nowPlayingTitle": "{{icon}} **Now playing**",
|
"nowPlayingTitle": "{{icon}} **Now playing**",
|
||||||
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
||||||
|
"queueRepeatMode": {
|
||||||
|
"off": "Disabled",
|
||||||
|
"track": "Track",
|
||||||
|
"queue": "Queue",
|
||||||
|
"autoplay": "Autoplay"
|
||||||
|
},
|
||||||
"requestedBy": "**Requested by:** {{user}}",
|
"requestedBy": "**Requested by:** {{user}}",
|
||||||
|
"unavailableAuthor": "Unavailable",
|
||||||
"unavailableDuration": "_No duration available._",
|
"unavailableDuration": "_No duration available._",
|
||||||
"unavailableRequestedBy": "Unavailable",
|
"unavailableRequestedBy": "Unavailable",
|
||||||
"unavailableTrackTitle": "Title unavailable",
|
"unavailableTrackTitle": "Title unavailable",
|
||||||
"unavailableTrackUrl": "**Unavailable**",
|
"unavailableTrackUrl": "**Unavailable**",
|
||||||
|
"unavailableSource": "Unavailable",
|
||||||
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
||||||
},
|
},
|
||||||
"statistics": {
|
"statistics": {
|
||||||
|
|||||||
Vendored
+46
-12
@@ -27,7 +27,13 @@ interface Resources {
|
|||||||
"options": {
|
"options": {
|
||||||
"type": {
|
"type": {
|
||||||
"name": "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": {
|
"options": {
|
||||||
"mode": {
|
"mode": {
|
||||||
"name": "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}}`**.",
|
"modeChanged": "{{icon}} **Loop mode changed**\nChanging loop mode from **`{{fromName}}`** to **`{{toName}}`**.",
|
||||||
"willAutoplay": "When the queue is empty, similar tracks will start playing!",
|
"willAutoplay": "When the queue is empty, similar tracks will start playing!",
|
||||||
"willNoLongerPlay": "The {{mode}} will no longer play on repeat!",
|
"willNoLongerPlay": "The {{mode}} will no longer play on repeat!",
|
||||||
"willNowPlay": "The {{mode}} will now play on repeat!",
|
"willNowPlay": "The {{mode}} will now play on repeat!"
|
||||||
"repeatMode": {
|
|
||||||
"off": "disabled",
|
|
||||||
"track": "track",
|
|
||||||
"queue": "queue",
|
|
||||||
"autoplay": "autoplay"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"lyrics": {
|
"lyrics": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -149,7 +155,16 @@ interface Resources {
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "nowplaying",
|
"name": "nowplaying",
|
||||||
"description": "Show information about the current track."
|
"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": {
|
"pause": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -157,7 +172,8 @@ interface Resources {
|
|||||||
"description": "Toggle pause for the current track."
|
"description": "Toggle pause for the current track."
|
||||||
},
|
},
|
||||||
"pauseConfirmation": "{{icon}} **Paused track**",
|
"pauseConfirmation": "{{icon}} **Paused track**",
|
||||||
"resumeConfirmation": "{{icon}} **Resumed track**"
|
"resumeConfirmation": "{{icon}} **Resumed track**",
|
||||||
|
"directSource": "Direct source"
|
||||||
},
|
},
|
||||||
"play": {
|
"play": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -228,7 +244,16 @@ interface Resources {
|
|||||||
"options": {
|
"options": {
|
||||||
"sort": {
|
"sort": {
|
||||||
"name": "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": {
|
"page": {
|
||||||
"name": "page",
|
"name": "page",
|
||||||
@@ -307,13 +332,22 @@ interface Resources {
|
|||||||
"footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)",
|
"footerPageNumber_one": "Page {{page}} of {{pageCount}} (1 track)",
|
||||||
"footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)",
|
"footerPageNumber": "Page {{page}} of {{pageCount}} ({{count}} tracks)",
|
||||||
"loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.",
|
"loopingInfo": "{{icon}} **Looping**\nLoop mode is set to **`{{loopMode}}`**. You can change it with {{loopCommand}}.",
|
||||||
|
"nowPausedTitle": "{{icon}} **Currently paused**",
|
||||||
"nowPlayingTitle": "{{icon}} **Now playing**",
|
"nowPlayingTitle": "{{icon}} **Now playing**",
|
||||||
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
"playingLive": "{{icon}} **`LIVE`** - Playing continuously from live source.",
|
||||||
|
"queueRepeatMode": {
|
||||||
|
"off": "Disabled",
|
||||||
|
"track": "Track",
|
||||||
|
"queue": "Queue",
|
||||||
|
"autoplay": "Autoplay"
|
||||||
|
},
|
||||||
"requestedBy": "**Requested by:** {{user}}",
|
"requestedBy": "**Requested by:** {{user}}",
|
||||||
|
"unavailableAuthor": "Unavailable",
|
||||||
"unavailableDuration": "_No duration available._",
|
"unavailableDuration": "_No duration available._",
|
||||||
"unavailableRequestedBy": "Unavailable",
|
"unavailableRequestedBy": "Unavailable",
|
||||||
"unavailableTrackTitle": "Title unavailable",
|
"unavailableTrackTitle": "Title unavailable",
|
||||||
"unavailableTrackUrl": "**Unavailable**",
|
"unavailableTrackUrl": "**Unavailable**",
|
||||||
|
"unavailableSource": "Unavailable",
|
||||||
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
"voiceChannelInfo": "Channel: {{channel}} ({{bitrate}}kbps)"
|
||||||
},
|
},
|
||||||
"statistics": {
|
"statistics": {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import {
|
|||||||
} from '../types/interactionTypes';
|
} from '../types/interactionTypes';
|
||||||
import { Validator, ValidatorParams } from '../types/utilTypes';
|
import { Validator, ValidatorParams } from '../types/utilTypes';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
import { formatSlashCommand } from '../common/formattingUtils';
|
|
||||||
|
|
||||||
abstract class BaseInteraction {
|
abstract class BaseInteraction {
|
||||||
embedOptions: EmbedOptions;
|
embedOptions: EmbedOptions;
|
||||||
@@ -162,34 +161,6 @@ abstract class BaseInteraction {
|
|||||||
return progressBar;
|
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(
|
abstract execute(
|
||||||
params: BaseInteractionParams
|
params: BaseInteractionParams
|
||||||
): Promise<Message<boolean> | ApplicationCommandOptionChoiceData | void>;
|
): Promise<Message<boolean> | ApplicationCommandOptionChoiceData | void>;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { QueueRepeatMode } from 'discord-player';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
|
import { EmbedOptions } from '../types/configTypes';
|
||||||
|
|
||||||
export function formatDuration(durationMs: number): string {
|
export function formatDuration(durationMs: number): string {
|
||||||
const durationDate: Date = new Date(0);
|
const durationDate: Date = new Date(0);
|
||||||
@@ -26,3 +28,45 @@ export function formatSlashCommand(commandName: string, translator: TFunction):
|
|||||||
});
|
});
|
||||||
return `**\`/${translatedName}\`**`;
|
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)
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
import assert from 'assert';
|
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 { lstatSync, readdirSync } from 'fs';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||||
@@ -20,6 +26,9 @@ translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
|||||||
backend: {
|
backend: {
|
||||||
loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'),
|
loadPath: join(localeDir, '{{lng}}', '{{ns}}.json'),
|
||||||
addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json')
|
addPath: join(localeDir, '{{lng}}', '{{ns}}.missing.json')
|
||||||
|
},
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,6 +50,7 @@ type CommandMetadata = {
|
|||||||
{
|
{
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
choices?: Record<string, string>;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
@@ -85,6 +95,29 @@ export function localizeCommand(command: Omit<SlashCommandBuilder, 'addSubcomman
|
|||||||
|
|
||||||
option.name_localizations = {};
|
option.name_localizations = {};
|
||||||
option.description_localizations = {};
|
option.description_localizations = {};
|
||||||
|
if (
|
||||||
|
(option.type === ApplicationCommandOptionType.String ||
|
||||||
|
option.type === ApplicationCommandOptionType.Integer) &&
|
||||||
|
option.choices
|
||||||
|
) {
|
||||||
|
assert(
|
||||||
|
englishOptionData.choices,
|
||||||
|
`Option ${option.name} in /${command.name} must have choice localizations.`
|
||||||
|
);
|
||||||
|
for (const choice of option.choices) {
|
||||||
|
choice.name_localizations = {};
|
||||||
|
assert(
|
||||||
|
choice.value !== undefined && choice.value !== null,
|
||||||
|
`Choice in option ${option.name} in /${command.name} must have a value.`
|
||||||
|
);
|
||||||
|
const stringifiedValue = choice.value.toString();
|
||||||
|
assert(
|
||||||
|
englishOptionData.choices[stringifiedValue],
|
||||||
|
`Choice ${choice.value} of option ${option.name} in /${command.name} must have an English localization.`
|
||||||
|
);
|
||||||
|
choice.name = englishOptionData.choices[stringifiedValue];
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const locale of DISCORD_LOCALES) {
|
for (const locale of DISCORD_LOCALES) {
|
||||||
const localeOptionData = (
|
const localeOptionData = (
|
||||||
translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined
|
translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined
|
||||||
@@ -98,6 +131,15 @@ export function localizeCommand(command: Omit<SlashCommandBuilder, 'addSubcomman
|
|||||||
if (localeOptionData.description) {
|
if (localeOptionData.description) {
|
||||||
option.description_localizations[locale] = localeOptionData.description;
|
option.description_localizations[locale] = localeOptionData.description;
|
||||||
}
|
}
|
||||||
|
if (localeOptionData.choices && option.type === ApplicationCommandOptionType.String && option.choices) {
|
||||||
|
for (const choice of option.choices) {
|
||||||
|
const localizedChoice = localeOptionData.choices[choice.value];
|
||||||
|
if (!localizedChoice) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
choice.name_localizations![locale] = localizedChoice;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ const equalizerFilterOptions: EqualizerFilterOptions = config.get('equalizerFilt
|
|||||||
|
|
||||||
class FiltersCommand extends BaseSlashCommandInteraction {
|
class FiltersCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
// TODO: Localize choices
|
|
||||||
// TODO: Implement system for localized filter names and descriptions
|
// TODO: Implement system for localized filter names and descriptions
|
||||||
const data = localizeCommand(
|
const data = localizeCommand(
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
@@ -45,10 +44,10 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('type')
|
.setName('type')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: 'FFmpeg', value: 'ffmpeg' },
|
{ value: 'ffmpeg', name: ' ' },
|
||||||
{ name: 'Biquad', value: 'biquad' },
|
{ value: 'biquad', name: ' ' },
|
||||||
{ name: 'Equalizer', value: 'equalizer' },
|
{ value: 'equalizer', name: ' ' },
|
||||||
{ name: 'Disable', value: 'disable' }
|
{ value: 'disable', name: ' ' }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { checkHistoryExists } from '../../../utils/validation/queueValidator';
|
|||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
import { formatSlashCommand } from '../../../common/formattingUtils';
|
import { formatRepeatModeDetailed, formatSlashCommand } from '../../../common/formattingUtils';
|
||||||
|
|
||||||
class HistoryCommand extends BaseSlashCommandInteraction {
|
class HistoryCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -130,24 +130,18 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
`${translator('musicPlayerCommon.nowPlayingTitle', {
|
||||||
icon: this.embedOptions.icons.audioPlaying
|
icon: this.embedOptions.icons.audioPlaying
|
||||||
}) +
|
})}\n` +
|
||||||
'\n' +
|
`${this.getFormattedTrackUrl(currentTrack, translator)}\n` +
|
||||||
this.getFormattedTrackUrl(currentTrack, translator) +
|
`${translator('musicPlayerCommon.requestedBy', {
|
||||||
'\n' +
|
|
||||||
translator('musicPlayerCommon.requestedBy', {
|
|
||||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||||
}) +
|
})}\n` +
|
||||||
'\n' +
|
`${this.getDisplayQueueProgressBar(queue, translator)}\n\n` +
|
||||||
this.getDisplayQueueProgressBar(queue, translator) +
|
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}\n` +
|
||||||
'\n' +
|
`${translator('commands.history.tracksInHistoryTitle', {
|
||||||
'\n' +
|
|
||||||
this.getDisplayRepeatMode(queue.repeatMode, translator) +
|
|
||||||
translator('commands.history.tracksInHistoryTitle', {
|
|
||||||
icon: this.embedOptions.icons.queue
|
icon: this.embedOptions.icons.queue
|
||||||
}) +
|
})}\n` +
|
||||||
'\n' +
|
|
||||||
historyTracksListString
|
historyTracksListString
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
|||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
|
import { formatRepeatMode } from '../../../common/formattingUtils';
|
||||||
|
|
||||||
class LoopCommand extends BaseSlashCommandInteraction {
|
class LoopCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
// TODO: Add choice localization support
|
|
||||||
const data = localizeCommand(
|
const data = localizeCommand(
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName('loop')
|
.setName('loop')
|
||||||
@@ -25,10 +25,10 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('mode')
|
.setName('mode')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: 'Track', value: QueueRepeatMode.TRACK },
|
{ value: QueueRepeatMode.TRACK, name: ' ' },
|
||||||
{ name: 'Queue', value: QueueRepeatMode.QUEUE },
|
{ value: QueueRepeatMode.QUEUE, name: ' ' },
|
||||||
{ name: 'Autoplay', value: QueueRepeatMode.AUTOPLAY },
|
{ value: QueueRepeatMode.AUTOPLAY, name: ' ' },
|
||||||
{ name: 'Disabled', value: QueueRepeatMode.OFF }
|
{ value: QueueRepeatMode.OFF, name: ' ' }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -79,7 +79,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const repeatModeEmbedIcon =
|
const repeatModeEmbedIcon =
|
||||||
currentRepeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
|
currentRepeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
|
||||||
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator);
|
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
|
||||||
|
|
||||||
logger.debug('Responding with info embed.');
|
logger.debug('Responding with info embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
@@ -102,7 +102,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
currentRepeatMode: QueueRepeatMode,
|
currentRepeatMode: QueueRepeatMode,
|
||||||
translator: TFunction
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator);
|
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
|
||||||
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
||||||
logger.debug('Responding with warning embed.');
|
logger.debug('Responding with warning embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
@@ -127,7 +127,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
toRepeatMode: QueueRepeatMode,
|
toRepeatMode: QueueRepeatMode,
|
||||||
translator: TFunction
|
translator: TFunction
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
|
const newRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
||||||
fromRepeatMode,
|
fromRepeatMode,
|
||||||
toRepeatMode,
|
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(
|
private getChangedRepeatModeEmbedReply(
|
||||||
fromRepeatMode: QueueRepeatMode,
|
fromRepeatMode: QueueRepeatMode,
|
||||||
toRepeatMode: QueueRepeatMode,
|
toRepeatMode: QueueRepeatMode,
|
||||||
translator: TFunction
|
translator: TFunction
|
||||||
): string {
|
): string {
|
||||||
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode, translator);
|
const fromRepeatModeEmbedName = formatRepeatMode(fromRepeatMode, translator);
|
||||||
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
|
const toRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||||
|
|
||||||
let repeatModeIcon = this.embedOptions.icons.looping;
|
let repeatModeIcon = this.embedOptions.icons.looping;
|
||||||
let newRepeatModeMessage: string = translator('commands.loop.willNowPlay', {
|
let newRepeatModeMessage: string = translator('commands.loop.willNowPlay', {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } fro
|
|||||||
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, useServerTranslator } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import { formatRepeatModeDetailed } from '../../../common/formattingUtils';
|
||||||
|
|
||||||
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -40,8 +42,12 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
const currentTrack: Track = queue.currentTrack!;
|
const currentTrack: Track = queue.currentTrack!;
|
||||||
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator);
|
const displayTrackUrl: string = this.getFormattedTrackUrl(currentTrack, translator);
|
||||||
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator);
|
const displayTrackRequestedBy: string = this.getDisplayTrackRequestedBy(currentTrack, translator);
|
||||||
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue);
|
const displayTrackPlayingStatus: string = this.getDisplayTrackPlayingStatus(queue, translator);
|
||||||
const displayQueueRepeatMode: string = this.getDisplayQueueRepeatMode(queue);
|
const displayQueueRepeatMode: string = formatRepeatModeDetailed(
|
||||||
|
queue.repeatMode,
|
||||||
|
this.embedOptions,
|
||||||
|
translator
|
||||||
|
);
|
||||||
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator);
|
const displayEmbedProgressBar: string = this.getDisplayQueueProgressBar(queue, translator);
|
||||||
|
|
||||||
const components: APIMessageActionRowComponent[] = [];
|
const components: APIMessageActionRowComponent[] = [];
|
||||||
@@ -69,9 +75,11 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
components.push(skipButton);
|
components.push(skipButton);
|
||||||
|
|
||||||
if (this.embedOptions.components.showButtonLabels) {
|
if (this.embedOptions.components.showButtonLabels) {
|
||||||
previousButton.label = 'Previous';
|
previousButton.label = translator('musicPlayerCommon.controls.previous');
|
||||||
playPauseButton.label = queue.node.isPaused() ? 'Resume' : 'Pause';
|
playPauseButton.label = queue.node.isPaused()
|
||||||
skipButton.label = 'Skip';
|
? translator('musicPlayerCommon.controls.resume')
|
||||||
|
: translator('musicPlayerCommon.controls.pause');
|
||||||
|
skipButton.label = translator('musicPlayerCommon.controls.skip');
|
||||||
}
|
}
|
||||||
|
|
||||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||||
@@ -87,13 +95,17 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
`${displayTrackPlayingStatus}\n` +
|
`${displayTrackPlayingStatus}\n` +
|
||||||
`${displayTrackUrl}\n` +
|
`${displayTrackUrl}\n` +
|
||||||
`**Requested by:** ${displayTrackRequestedBy}\n` +
|
`${translator('musicPlayerCommon.requestedBy', {
|
||||||
|
user: displayTrackRequestedBy
|
||||||
|
})}\n` +
|
||||||
`${displayEmbedProgressBar}\n\n ` +
|
`${displayEmbedProgressBar}\n\n ` +
|
||||||
`${displayQueueRepeatMode}\n\n`
|
`${displayQueueRepeatMode}\n\n`
|
||||||
)
|
)
|
||||||
.addFields(this.getEmbedFields(currentTrack))
|
.addFields(this.getEmbedFields(currentTrack, translator))
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: tracksInQueueCount ? `${tracksInQueueCount} other tracks in the queue...` : ' '
|
text: tracksInQueueCount
|
||||||
|
? translator('commands.nowplaying.otherTracksInQueue', { count: tracksInQueueCount })
|
||||||
|
: ' '
|
||||||
})
|
})
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
.setThumbnail(this.getTrackThumbnailUrl(queue.currentTrack!))
|
||||||
.setColor(this.embedOptions.colors.info)
|
.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;
|
const trackMetadata = currentTrack?.metadata as TrackMetadata;
|
||||||
|
|
||||||
let displayPlays: string =
|
return translator('commands.nowplaying.playCount', {
|
||||||
(currentTrack?.views || trackMetadata?.bridge?.views || 0).toLocaleString('en-US') ?? '0';
|
count: currentTrack?.views || trackMetadata?.bridge?.views || 0
|
||||||
|
});
|
||||||
if (displayPlays === '0') {
|
|
||||||
displayPlays = 'Unavailable';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return displayPlays;
|
private getDisplayTrackAuthor(currentTrack: Track | undefined, translator: TFunction): string {
|
||||||
}
|
let author = currentTrack?.author;
|
||||||
|
if (!author || author === 'cdn.discordapp.com') {
|
||||||
private getDisplayTrackAuthor(currentTrack: Track | undefined): string {
|
author = translator('musicPlayerCommon.unavailableAuthor');
|
||||||
let author: string = currentTrack?.author ? currentTrack.author : 'Unavailable';
|
|
||||||
if (author === 'cdn.discordapp.com') {
|
|
||||||
author = 'Unavailable';
|
|
||||||
}
|
}
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTrackSourceString(currentTrack: Track): string {
|
private getTrackSourceString(currentTrack: Track, translator: TFunction): string {
|
||||||
const sourceStringsFormatted: Map<string, string> = new Map([
|
const sourceStringsFormatted: Map<string, string> = new Map([
|
||||||
['youtube', 'YouTube'],
|
['youtube', 'YouTube'],
|
||||||
['soundcloud', 'SoundCloud'],
|
['soundcloud', 'SoundCloud'],
|
||||||
['spotify', 'Spotify'],
|
['spotify', 'Spotify'],
|
||||||
['apple_music', 'Apple Music'],
|
['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 {
|
private getTrackSourceIcon(currentTrack: Track): string {
|
||||||
@@ -147,59 +156,38 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
return sourceIcons.get(currentTrack.raw.source!) ?? '';
|
return sourceIcons.get(currentTrack.raw.source!) ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDisplayTrackSource(currentTrack: Track) {
|
private getDisplayTrackSource(currentTrack: Track, translator: TFunction) {
|
||||||
const trackSource: string = this.getTrackSourceString(currentTrack) ?? 'Unavailable';
|
const trackSource: string = this.getTrackSourceString(currentTrack, translator);
|
||||||
const trackSourceIcon: string = this.getTrackSourceIcon(currentTrack) ?? '';
|
const trackSourceIcon: string = this.getTrackSourceIcon(currentTrack) ?? '';
|
||||||
|
|
||||||
return `**${trackSourceIcon} [${trackSource}](${currentTrack.raw.url ?? currentTrack.url})**`;
|
return `**${trackSourceIcon} [${trackSource}](${currentTrack.raw.url ?? currentTrack.url})**`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRepeatModeString(repeatMode: number): string {
|
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||||
const loopModesFormatted: Map<number, string> = 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 => {
|
|
||||||
return queue.node.isPaused()
|
return queue.node.isPaused()
|
||||||
? '**Currently Paused**'
|
? translator('musicPlayerCommon.nowPausedTitle', {
|
||||||
: `**${this.embedOptions.icons.audioPlaying} Now Playing**`;
|
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[] = [
|
const fields: EmbedField[] = [
|
||||||
{
|
{
|
||||||
name: '**Author**',
|
name: translator('commands.nowplaying.embedFields.author'),
|
||||||
value: this.getDisplayTrackAuthor(currentTrack),
|
value: this.getDisplayTrackAuthor(currentTrack, translator),
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '**Plays**',
|
name: translator('commands.nowplaying.embedFields.plays'),
|
||||||
value: this.getDisplayPlays(currentTrack),
|
value: this.getDisplayPlays(currentTrack, translator),
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '**Track source**',
|
name: translator('commands.nowplaying.embedFields.source'),
|
||||||
value: this.getDisplayTrackSource(currentTrack),
|
value: this.getDisplayTrackSource(currentTrack, translator),
|
||||||
inline: true
|
inline: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ 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 { formatDuration } from '../../../common/formattingUtils';
|
import { formatDuration, formatRepeatModeDetailed } from '../../../common/formattingUtils';
|
||||||
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
@@ -123,20 +123,18 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
translator('musicPlayerCommon.nowPlayingTitle', {
|
translator('musicPlayerCommon.nowPlayingTitle', {
|
||||||
icon: this.embedOptions.icons.audioPlaying
|
icon: this.embedOptions.icons.audioPlaying
|
||||||
}) +
|
}) +
|
||||||
|
'\n' +
|
||||||
this.getFormattedTrackUrl(currentTrack, translator) +
|
this.getFormattedTrackUrl(currentTrack, translator) +
|
||||||
'\n' +
|
'\n' +
|
||||||
translator('musicPlayerCommon.requestedBy', {
|
translator('musicPlayerCommon.requestedBy', {
|
||||||
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
user: this.getDisplayTrackRequestedBy(currentTrack, translator)
|
||||||
}) +
|
}) +
|
||||||
'\n' +
|
'\n' +
|
||||||
this.getDisplayQueueProgressBar(queue, translator) +
|
`${this.getDisplayQueueProgressBar(queue, translator)}\n\n` +
|
||||||
'\n' +
|
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}\n` +
|
||||||
'\n' +
|
`${translator('commands.queue.tracksInQueueTitle', {
|
||||||
this.getDisplayRepeatMode(queue.repeatMode, translator) +
|
|
||||||
translator('commands.queue.tracksInQueueTitle', {
|
|
||||||
icon: this.embedOptions.icons.queue
|
icon: this.embedOptions.icons.queue
|
||||||
}) +
|
})}\n` +
|
||||||
'\n' +
|
|
||||||
queueTracksListString
|
queueTracksListString
|
||||||
)
|
)
|
||||||
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
.setThumbnail(this.getTrackThumbnailUrl(currentTrack))
|
||||||
@@ -163,8 +161,10 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode, translator)}` +
|
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator)}` +
|
||||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n` +
|
`${translator('commands.queue.tracksInQueueTitle', {
|
||||||
|
icon: this.embedOptions.icons.queue
|
||||||
|
})}\n` +
|
||||||
queueTracksListString
|
queueTracksListString
|
||||||
)
|
)
|
||||||
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } 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';
|
||||||
@@ -27,7 +27,7 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
queue.setRepeatMode(0);
|
queue.setRepeatMode(QueueRepeatMode.OFF);
|
||||||
queue.clear();
|
queue.clear();
|
||||||
queue.node.stop();
|
queue.node.stop();
|
||||||
logger.debug('Cleared and stopped the queue.');
|
logger.debug('Cleared and stopped the queue.');
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { localizeCommand } from '../../../common/localeUtil';
|
|||||||
|
|
||||||
class ShardsCommand extends BaseSlashCommandInteraction {
|
class ShardsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
// TODO: Localize choices
|
|
||||||
const data = localizeCommand(
|
const data = localizeCommand(
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName('shards')
|
.setName('shards')
|
||||||
@@ -23,13 +22,13 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('sort')
|
.setName('sort')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: 'None (Shard ID)', value: 'none' },
|
{ value: 'none', name: ' ' },
|
||||||
{ name: 'Memory usage', value: 'memory' },
|
{ value: 'memory', name: ' ' },
|
||||||
{ name: 'Voice Connections', value: 'connections' },
|
{ value: 'connections', name: ' ' },
|
||||||
{ name: 'Tracks', value: 'tracks' },
|
{ value: 'tracks', name: ' ' },
|
||||||
{ name: 'Listeners', value: 'listeners' },
|
{ value: 'listeners', name: ' ' },
|
||||||
{ name: 'Guilds', value: 'guilds' },
|
{ value: 'guilds', name: ' ' },
|
||||||
{ name: 'Members', value: 'members' }
|
{ value: 'members', name: ' ' }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addIntegerOption((option) => option.setName('page').setMinValue(1))
|
.addIntegerOption((option) => option.setName('page').setMinValue(1))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation
|
|||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
import { useServerTranslator } from '../../common/localeUtil';
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { formatRepeatModeDetailed } from '../../common/formattingUtils';
|
||||||
|
|
||||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -85,7 +86,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
|||||||
`**${this.embedOptions.icons.pauseResumed} ${
|
`**${this.embedOptions.icons.pauseResumed} ${
|
||||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}`
|
||||||
)
|
)
|
||||||
.setThumbnail(track.thumbnail)
|
.setThumbnail(track.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation
|
|||||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
import { useServerTranslator } from '../../common/localeUtil';
|
import { useServerTranslator } from '../../common/localeUtil';
|
||||||
|
import { formatRepeatModeDetailed } from '../../common/formattingUtils';
|
||||||
|
|
||||||
class ActionSkipButton extends BaseComponentInteraction {
|
class ActionSkipButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -79,7 +80,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
||||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
||||||
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
`${formatRepeatModeDetailed(queue.repeatMode, this.embedOptions, translator, 'success')}`
|
||||||
)
|
)
|
||||||
.setThumbnail(skippedTrack.thumbnail)
|
.setThumbnail(skippedTrack.thumbnail)
|
||||||
.setColor(this.embedOptions.colors.success);
|
.setColor(this.embedOptions.colors.success);
|
||||||
|
|||||||
Vendored
+1
@@ -63,6 +63,7 @@ export type EmbedOptions = {
|
|||||||
nextTrack: string;
|
nextTrack: string;
|
||||||
previousTrack: string;
|
previousTrack: string;
|
||||||
pauseResumeTrack: string;
|
pauseResumeTrack: string;
|
||||||
|
paused: string;
|
||||||
shuffleQueue: string;
|
shuffleQueue: string;
|
||||||
loop: string;
|
loop: string;
|
||||||
loopAction: string;
|
loopAction: string;
|
||||||
|
|||||||
Reference in new issue
Block a user