Transcribe everything

Untranscribed sections are marked TODO
This commit is contained in:
tacheometry committed 2023-12-16 00:15:49 +02:00
1 parent 5398831944
commit 694767fc03
32 files changed
+1034 -392

No files matched your search

+61 -28
View File
@@ -11,7 +11,8 @@ import { BaseSlashCommandInteraction } from '../../../classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
import { checkQueueExists } from '../../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
import { localizeCommand } from '../../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../../common/localeUtil';
import { TFunction } from 'i18next';
class LoopCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -37,6 +38,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
const { executionId, interaction } = params;
const logger = this.getLogger(this.name, executionId, interaction);
const translator = useServerTranslator(interaction);
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
@@ -50,34 +52,44 @@ class LoopCommand extends BaseSlashCommandInteraction {
const currentRepeatMode: QueueRepeatMode = queue.repeatMode;
if (!userInputRepeatMode && userInputRepeatMode !== 0) {
return await this.handleNoInputMode(logger, interaction, currentRepeatMode);
return await this.handleNoInputMode(logger, interaction, currentRepeatMode, translator);
}
if (userInputRepeatMode === currentRepeatMode) {
return await this.handleSameMode(logger, interaction, userInputRepeatMode);
return await this.handleSameMode(logger, interaction, userInputRepeatMode, translator);
}
return await this.handleChangeMode(logger, interaction, queue, currentRepeatMode, userInputRepeatMode);
return await this.handleChangeMode(
logger,
interaction,
queue,
currentRepeatMode,
userInputRepeatMode,
translator
);
}
private async handleNoInputMode(
logger: Logger,
interaction: ChatInputCommandInteraction,
currentRepeatMode: QueueRepeatMode
currentRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
logger.debug('No repeat mode was provided, responding with current repeat mode.');
const repeatModeEmbedIcon =
currentRepeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode);
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator);
logger.debug('Responding with info embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**${repeatModeEmbedIcon} Current loop mode**\n` +
`The looping mode is currently set to **\`${repeatModeEmbedName}\`**.`
translator('commands.loop.loopModeInformation', {
icon: repeatModeEmbedIcon,
mode: repeatModeEmbedName
})
)
.setColor(this.embedOptions.colors.info)
]
@@ -87,17 +99,20 @@ class LoopCommand extends BaseSlashCommandInteraction {
private async handleSameMode(
logger: Logger,
interaction: ChatInputCommandInteraction,
currentRepeatMode: QueueRepeatMode
currentRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode);
const repeatModeEmbedName = this.getRepeatModeEmbedName(currentRepeatMode, translator);
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
logger.debug('Responding with warning embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**${this.embedOptions.icons.warning} Oops!**\n` +
`Loop mode is already **\`${repeatModeEmbedName}\`**.`
translator('commands.loop.alreadySet', {
icon: this.embedOptions.icons.warning,
mode: repeatModeEmbedName
})
)
.setColor(this.embedOptions.colors.warning)
]
@@ -109,10 +124,15 @@ class LoopCommand extends BaseSlashCommandInteraction {
interaction: ChatInputCommandInteraction,
queue: GuildQueue,
fromRepeatMode: QueueRepeatMode,
toRepeatMode: QueueRepeatMode
toRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(fromRepeatMode, toRepeatMode);
const newRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
fromRepeatMode,
toRepeatMode,
translator
);
queue.setRepeatMode(toRepeatMode);
logger.debug(`Loop mode changed to '${newRepeatModeEmbedName}'.`);
@@ -128,35 +148,48 @@ class LoopCommand extends BaseSlashCommandInteraction {
});
}
private getRepeatModeEmbedName(repeatMode: QueueRepeatMode): string {
private getRepeatModeEmbedName(repeatMode: QueueRepeatMode, translator: TFunction): string {
const repeatModeEmbedString: { [key in QueueRepeatMode]: string } = {
[QueueRepeatMode.OFF]: 'disabled',
[QueueRepeatMode.TRACK]: 'track',
[QueueRepeatMode.QUEUE]: 'queue',
[QueueRepeatMode.AUTOPLAY]: 'autoplay'
[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): string {
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode);
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode);
private getChangedRepeatModeEmbedReply(
fromRepeatMode: QueueRepeatMode,
toRepeatMode: QueueRepeatMode,
translator: TFunction
): string {
const fromRepeatModeEmbedName = this.getRepeatModeEmbedName(fromRepeatMode, translator);
const toRepeatModeEmbedName = this.getRepeatModeEmbedName(toRepeatMode, translator);
let repeatModeIcon = this.embedOptions.icons.looping;
let newRepeatModeMessage = `The ${toRepeatModeEmbedName} will now play on repeat!`;
let newRepeatModeMessage: string = translator('commands.loop.willNowPlay', {
mode: toRepeatModeEmbedName
});
if (toRepeatMode === QueueRepeatMode.OFF) {
repeatModeIcon = this.embedOptions.icons.success;
newRepeatModeMessage = `The ${fromRepeatModeEmbedName} will no longer play on repeat!`;
newRepeatModeMessage = translator('commands.loop.willNoLongerPlay', {
mode: fromRepeatModeEmbedName
});
} else if (toRepeatMode === QueueRepeatMode.AUTOPLAY) {
repeatModeIcon = this.embedOptions.icons.autoplaying;
newRepeatModeMessage = 'When the queue is empty, similar tracks will start playing!';
newRepeatModeMessage = translator('commands.loop.willAutoplay');
}
return (
`**${repeatModeIcon} Loop mode changed**\n` +
`Changing loop mode from **\`${fromRepeatModeEmbedName}\`** to **\`${toRepeatModeEmbedName}\`**.\n\n` +
translator('commands.loop.modeChanged', {
icon: repeatModeIcon,
fromName: fromRepeatModeEmbedName,
toName: toRepeatModeEmbedName
}) +
'\n' +
'\n' +
newRepeatModeMessage
);
}