mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 22:16:13 +00:00
Transcribe everything
Untranscribed sections are marked TODO
This commit is contained in:
32 files changed
+1034
-392
No files matched your search
@@ -4,6 +4,8 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +15,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -41,7 +44,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
}
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.handleSuccess(interaction, currentTrack, queue);
|
||||
return await this.handleSuccess(interaction, currentTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||
@@ -70,14 +73,19 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, track: Track, queue: GuildQueue) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
track: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.pauseResumed} ${
|
||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
||||
}**\n ${this.getDisplayTrackDurationAndUrl(queue.currentTrack!, translator)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
||||
)
|
||||
.setThumbnail(track.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -5,6 +5,9 @@ import { BaseComponentParams, BaseComponentReturnType } from '../../types/intera
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { Logger } from 'pino';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/formattingUtils';
|
||||
|
||||
class ActionPreviousButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -14,6 +17,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const history: GuildQueueHistory = useHistory(interaction.guild!.id)!;
|
||||
@@ -33,32 +37,39 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
return await this.handleAlreadySkipped(interaction);
|
||||
}
|
||||
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history);
|
||||
return await this.handleBackToPreviousTrack(logger, interaction, history, translator);
|
||||
}
|
||||
|
||||
private async handleBackToPreviousTrack(
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
history: GuildQueueHistory
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
) {
|
||||
if (history.tracks.data.length === 0) {
|
||||
return await this.handleNoTracksInHistory(logger, interaction);
|
||||
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||
}
|
||||
|
||||
await history.back();
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
const currentTrack: Track = queue.currentTrack!;
|
||||
logger.debug('Recovered track from history.');
|
||||
return await this.handleSuccess(interaction, currentTrack);
|
||||
return await this.handleSuccess(interaction, currentTrack, translator);
|
||||
}
|
||||
private async handleNoTracksInHistory(logger: Logger, interaction: MessageComponentInteraction) {
|
||||
private async handleNoTracksInHistory(
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
translator: TFunction
|
||||
) {
|
||||
logger.debug('No tracks in history.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.warning} Oops!**\n` +
|
||||
'The history is empty, add some tracks with **`/play`**!'
|
||||
translator('commands.back.trackHistoryEmpty', {
|
||||
icon: this.embedOptions.icons.warning,
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.warning)
|
||||
]
|
||||
@@ -91,12 +102,16 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, recoveredTrack: Track) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
recoveredTrack: Track,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.back} Recovered track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack)}`
|
||||
`${this.getDisplayTrackDurationAndUrl(recoveredTrack, translator)}`
|
||||
)
|
||||
.setThumbnail(recoveredTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -4,6 +4,8 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
class ActionSkipButton extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -13,6 +15,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -36,7 +39,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
logger.debug('Skipped the track.');
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.handleSuccess(interaction, skippedTrack, queue);
|
||||
return await this.handleSuccess(interaction, skippedTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleNoQueue(interaction: MessageComponentInteraction) {
|
||||
@@ -65,13 +68,18 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSuccess(interaction: MessageComponentInteraction, skippedTrack: Track, queue: GuildQueue) {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
skippedTrack: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.skipped} Skipped track**\n` +
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, 'success')}`
|
||||
`${this.getDisplayTrackDurationAndUrl(skippedTrack, translator)}\n\n` +
|
||||
`${this.getDisplayRepeatMode(queue.repeatMode, translator, 'success')}`
|
||||
)
|
||||
.setThumbnail(skippedTrack.thumbnail)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BaseComponentInteraction } from '../../classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
|
||||
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
constructor() {
|
||||
@@ -14,6 +15,7 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
|
||||
@@ -31,8 +33,9 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
||||
'All audio filters have been disabled.'
|
||||
translator('commands.filters.allFiltersDisabled', {
|
||||
icon: this.embedOptions.icons.success
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
],
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||
import { useServerTranslator } from '../../common/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||
@@ -25,6 +27,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||
const { executionId, interaction, referenceId } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
const translator = useServerTranslator(interaction);
|
||||
const filterType = referenceId;
|
||||
|
||||
logger.debug('Received select menu interaction.');
|
||||
@@ -41,16 +44,34 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
this.resetFilters(queue, logger);
|
||||
|
||||
if (selectMenuInteraction.values.length === 0) {
|
||||
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction);
|
||||
return await this.replyWithDisabledFiltersEmbed(logger, selectMenuInteraction, translator);
|
||||
}
|
||||
|
||||
switch (filterType) {
|
||||
case 'ffmpeg':
|
||||
return await this.handleFfmpegFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleFfmpegFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
case 'biquad':
|
||||
return await this.handleBiquadFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleBiquadFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
case 'equalizer':
|
||||
return await this.handleEqualizerFilterToggle(logger, selectMenuInteraction, queue, filterType);
|
||||
return await this.handleEqualizerFilterToggle(
|
||||
logger,
|
||||
selectMenuInteraction,
|
||||
queue,
|
||||
filterType,
|
||||
translator
|
||||
);
|
||||
default:
|
||||
logger.warn(`Unknown filter type '${filterType}'.`);
|
||||
return;
|
||||
@@ -61,37 +82,40 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.addFfmpegNormalizerIfRequired(selectMenuInteraction);
|
||||
this.toggleFfmpegFilters(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private async handleBiquadFilterToggle(
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.toggleBiquadFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private async handleEqualizerFilterToggle(
|
||||
logger: Logger,
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
this.toggleEqualizerFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType);
|
||||
return await this.sendFiltersToggledSuccessEmbed(logger, selectMenuInteraction, filterType, translator);
|
||||
}
|
||||
|
||||
private toggleFfmpegFilters(
|
||||
@@ -172,25 +196,33 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
private sendFiltersToggledSuccessEmbed(
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction,
|
||||
filterType: string
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return interaction.editReply({
|
||||
embeds: [this.buildSuccessEmbed(interaction, filterType)],
|
||||
embeds: [this.buildSuccessEmbed(interaction, filterType, translator)],
|
||||
components: []
|
||||
});
|
||||
}
|
||||
|
||||
private buildSuccessEmbed(selectMenuInteraction: StringSelectMenuInteraction, filterType: string): EmbedBuilder {
|
||||
private buildSuccessEmbed(
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
): EmbedBuilder {
|
||||
const availableFilters: FilterOption[] = this.getAvailableFilters(filterType);
|
||||
const enabledFilters: string = this.getEnabledFilters(selectMenuInteraction, availableFilters);
|
||||
|
||||
return new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(selectMenuInteraction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Filters toggled**\n` +
|
||||
`Now using these ${filterType} filters:\n` +
|
||||
`${enabledFilters}`
|
||||
translator('commands.filters.nowUsingFilters', {
|
||||
icon: this.embedOptions.icons.success,
|
||||
mode: filterType
|
||||
}) +
|
||||
'\n' +
|
||||
enabledFilters
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success);
|
||||
}
|
||||
@@ -243,7 +275,8 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
|
||||
private async replyWithDisabledFiltersEmbed(
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction
|
||||
interaction: StringSelectMenuInteraction,
|
||||
translator: TFunction
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
@@ -251,8 +284,9 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
.setDescription(
|
||||
`**${this.embedOptions.icons.success} Disabled filters**\n` +
|
||||
'All audio filters have been disabled.'
|
||||
translator('commands.filters.allFiltersDisabled', {
|
||||
icon: this.embedOptions.icons.success
|
||||
})
|
||||
)
|
||||
.setColor(this.embedOptions.colors.success)
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user