mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-01 14:38:48 +00:00
Export type in locale util
This commit is contained in:
1 parent
e1b0aea7fc
commit
115b9cc0b2
26 files changed
+131
-150
No files matched your search
@@ -25,7 +25,7 @@ import {
|
||||
BaseSlashCommandReturnType
|
||||
} from '../../types/interactionTypes';
|
||||
import { Validator, ValidatorParams } from '../../types/utilTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
import { Translator } from '../utils/localeUtil';
|
||||
|
||||
abstract class BaseInteraction {
|
||||
embedOptions: EmbedOptions;
|
||||
@@ -72,7 +72,7 @@ abstract class BaseInteraction {
|
||||
return durationFormat;
|
||||
}
|
||||
|
||||
protected getFormattedTrackUrl(track: Track, translator: TFunction): string {
|
||||
protected getFormattedTrackUrl(track: Track, translator: Translator): string {
|
||||
const trackTitle = track.title ?? translator('musicPlayerCommon.unavailableTrackTitle');
|
||||
const trackUrl = track.url ?? track.raw.url;
|
||||
if (!trackTitle || !trackUrl) {
|
||||
@@ -81,7 +81,7 @@ abstract class BaseInteraction {
|
||||
return `**[${trackTitle}](${trackUrl})**`;
|
||||
}
|
||||
|
||||
protected getDisplayTrackDurationAndUrl(track: Track, translator: TFunction): string {
|
||||
protected getDisplayTrackDurationAndUrl(track: Track, translator: Translator): string {
|
||||
const formattedDuration = this.getFormattedDuration(track);
|
||||
const formattedUrl = this.getFormattedTrackUrl(track, translator);
|
||||
|
||||
@@ -117,7 +117,7 @@ abstract class BaseInteraction {
|
||||
protected getFooterDisplayPageInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue | GuildQueueHistory,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): EmbedFooterData {
|
||||
const pageIndex: number = (interaction.options.getInteger('page') || 1) - 1;
|
||||
const totalPages: number = Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||
@@ -130,13 +130,13 @@ abstract class BaseInteraction {
|
||||
};
|
||||
}
|
||||
|
||||
protected getDisplayTrackRequestedBy = (track: Track, translator: TFunction): string => {
|
||||
protected getDisplayTrackRequestedBy = (track: Track, translator: Translator): string => {
|
||||
return track.requestedBy
|
||||
? `<@${track.requestedBy.id}>`
|
||||
: translator('musicPlayerCommon.unavailableRequestedBy');
|
||||
};
|
||||
|
||||
protected getDisplayQueueProgressBar(queue: GuildQueue, translator: TFunction): string {
|
||||
protected getDisplayQueueProgressBar(queue: GuildQueue, translator: Translator): string {
|
||||
const timestamp: PlayerTimestamp = queue.node.getTimestamp()!;
|
||||
let progressBar: string = `**\`${timestamp.current.label}\`** ${queue.node.createProgressBar({
|
||||
queue: false,
|
||||
@@ -189,7 +189,7 @@ abstract class BaseInteractionWithEmbedResponse extends BaseInteraction {
|
||||
protected getEmbedQueueAuthor(
|
||||
interaction: MessageComponentInteraction | ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): EmbedAuthorOptions {
|
||||
const bitrate = queue.channel ? queue.channel.bitrate / 1000 : 0;
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Track } from 'discord-player';
|
||||
import { TFunction } from 'i18next';
|
||||
import { Translator } from './localeUtil';
|
||||
|
||||
export function shouldUseLastQuery(query: string, lastQuery?: string, timestamp?: number): boolean {
|
||||
return Boolean(
|
||||
@@ -11,7 +11,7 @@ export function isQueryTooShort(query: string): boolean {
|
||||
return query.length < 3;
|
||||
}
|
||||
|
||||
export function getTrackName(track: Track, translator: TFunction): string {
|
||||
export function getTrackName(track: Track, translator: Translator): string {
|
||||
const name = translator('autocomplete.trackName', {
|
||||
title: track.title,
|
||||
author: track.author
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { QueueRepeatMode } from 'discord-player';
|
||||
import { TFunction } from 'i18next';
|
||||
import { Translator } from './localeUtil';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
|
||||
export function formatDuration(durationMs: number): string {
|
||||
@@ -22,14 +22,14 @@ export function formatDuration(durationMs: number): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSlashCommand(commandName: string, translator: TFunction): string {
|
||||
export function formatSlashCommand(commandName: string, translator: Translator): string {
|
||||
const translatedName = translator(`commands.${commandName}.metadata.name`, {
|
||||
defaultValue: commandName
|
||||
});
|
||||
return `**\`/${translatedName}\`**`;
|
||||
}
|
||||
|
||||
export function formatRepeatMode(repeatMode: QueueRepeatMode, translator: TFunction): string {
|
||||
export function formatRepeatMode(repeatMode: QueueRepeatMode, translator: Translator): string {
|
||||
switch (repeatMode) {
|
||||
case QueueRepeatMode.AUTOPLAY:
|
||||
return translator('musicPlayerCommon.queueRepeatMode.autoplay');
|
||||
@@ -45,7 +45,7 @@ export function formatRepeatMode(repeatMode: QueueRepeatMode, translator: TFunct
|
||||
export function formatRepeatModeDetailed(
|
||||
repeatMode: QueueRepeatMode,
|
||||
embedOptions: EmbedOptions,
|
||||
translator: TFunction,
|
||||
translator: Translator,
|
||||
state: string = 'info'
|
||||
) {
|
||||
let icon: string;
|
||||
|
||||
@@ -10,10 +10,12 @@ import {
|
||||
SlashCommandSubcommandsOnlyBuilder
|
||||
} from 'discord.js';
|
||||
import { lstatSync, readdirSync } from 'fs';
|
||||
import i18n from 'i18next';
|
||||
import i18n, { TFunction } from 'i18next';
|
||||
import i18nextFsBackend, { FsBackendOptions } from 'i18next-fs-backend';
|
||||
import { join } from 'path';
|
||||
|
||||
export type Translator = TFunction;
|
||||
|
||||
export const translatorInstance = i18n.createInstance();
|
||||
const localeDir = join(__dirname, '..', '..', '..', 'locales');
|
||||
|
||||
@@ -36,15 +38,15 @@ translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
||||
}
|
||||
});
|
||||
|
||||
export function useServerTranslator(interaction: BaseInteraction) {
|
||||
export function useServerTranslator(interaction: BaseInteraction): Translator {
|
||||
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en-US');
|
||||
}
|
||||
|
||||
export function useUserTranslator(interaction: BaseInteraction) {
|
||||
export function useUserTranslator(interaction: BaseInteraction): Translator {
|
||||
return translatorInstance.getFixedT(interaction.locale ?? 'en-US');
|
||||
}
|
||||
|
||||
export function useLanguageTranslator(language: LocaleString) {
|
||||
export function useLanguageTranslator(language: LocaleString): Translator {
|
||||
return translatorInstance.getFixedT(language ?? 'en-US');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ import osu from 'node-os-utils';
|
||||
import { ExtendedClient } from '../../types/clientTypes';
|
||||
import { fetchTotalGuildStatistics, fetchTotalPlayerStatistics } from './shardUtils';
|
||||
import { getUptimeFormatted } from './getUptimeFormatted';
|
||||
import { TFunction } from 'i18next';
|
||||
import { Translator } from './localeUtil';
|
||||
|
||||
export async function getBotStatistics(
|
||||
client: ExtendedClient,
|
||||
version: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<string> {
|
||||
const releaseVersion: string = version;
|
||||
const { totalGuildCount, totalMemberCount } = await fetchTotalGuildStatistics(client);
|
||||
@@ -27,7 +27,7 @@ export async function getBotStatistics(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getPlayerStatistics(client: ExtendedClient, translator: TFunction): Promise<string> {
|
||||
export async function getPlayerStatistics(client: ExtendedClient, translator: Translator): Promise<string> {
|
||||
const { totalVoiceConnections, totalTracksInQueues, totalListeners } = await fetchTotalPlayerStatistics(client);
|
||||
|
||||
return (
|
||||
@@ -45,7 +45,7 @@ export async function getPlayerStatistics(client: ExtendedClient, translator: TF
|
||||
);
|
||||
}
|
||||
|
||||
export async function getSystemStatus(executionId: string, extended: boolean, translator: TFunction): Promise<string> {
|
||||
export async function getSystemStatus(executionId: string, extended: boolean, translator: Translator): Promise<string> {
|
||||
const uptimeString: string = getUptimeFormatted({ executionId });
|
||||
const usedMemoryInMB: number = Math.ceil((await osu.mem.info()).usedMemMb);
|
||||
const cpuUsage: number = await osu.cpu.usage();
|
||||
@@ -74,6 +74,6 @@ export async function getSystemStatus(executionId: string, extended: boolean, tr
|
||||
);
|
||||
}
|
||||
|
||||
export function getDiscordStatus(client: ExtendedClient, translator: TFunction): string {
|
||||
export function getDiscordStatus(client: ExtendedClient, translator: Translator): string {
|
||||
return translator('statistics.discordStatus.apiLatency', { value: client.ws.ping });
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import { Logger } from '../../common/services/logger';
|
||||
import { BaseAutocompleteInteraction } from '../../common/classes/interactions';
|
||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/utils/autocompleteUtils';
|
||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useUserTranslator } from '../../common/utils/localeUtil';
|
||||
import { useUserTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
private recentQueries = new Map<string, RecentQuery>();
|
||||
|
||||
@@ -47,7 +46,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
private async getAutocompleteChoices(
|
||||
query: string,
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
const genius = lyricsExtractor();
|
||||
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
||||
@@ -62,7 +61,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
private async getAutocompleteChoicesFallback(
|
||||
query: string,
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
logger.debug(`No Genius lyrics found for query '${query}', using player.search() as fallback.`);
|
||||
|
||||
@@ -77,7 +76,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
|
||||
private getAutocompleteChoicesFromLyricsResult(
|
||||
lyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): ApplicationCommandOptionChoiceData<string>[] {
|
||||
return [
|
||||
{
|
||||
@@ -87,7 +86,7 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
||||
];
|
||||
}
|
||||
|
||||
private getLyricsResultName(lyricsResult: LyricsData, translator: TFunction): string {
|
||||
private getLyricsResultName(lyricsResult: LyricsData, translator: Translator): string {
|
||||
return translator('commands.lyrics.autocompleteSearchResult', {
|
||||
title: lyricsResult.title,
|
||||
artist: lyricsResult.artist.name
|
||||
|
||||
@@ -3,8 +3,7 @@ import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||
import { BaseAutocompleteInteraction } from '../../common/classes/interactions';
|
||||
import { getTrackName, isQueryTooShort, shouldUseLastQuery } from '../../common/utils/autocompleteUtils';
|
||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType, RecentQuery } from '../../types/interactionTypes';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useUserTranslator } from '../../common/utils/localeUtil';
|
||||
import { useUserTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { transformQuery } from '../../common/validation/searchQueryValidator';
|
||||
|
||||
class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
@@ -53,7 +52,7 @@ class PlayAutocomplete extends BaseAutocompleteInteraction {
|
||||
|
||||
private async getAutocompleteChoices(
|
||||
query: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<ApplicationCommandOptionChoiceData<string>[]> {
|
||||
const player: Player = useMainPlayer()!;
|
||||
const searchResults: SearchResult = await player.search(query);
|
||||
|
||||
@@ -4,8 +4,7 @@ import { BaseComponentInteraction } from '../../common/classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatModeDetailed } from '../../common/utils/formattingUtils';
|
||||
|
||||
class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
@@ -44,7 +43,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
return await this.handleSuccess(interaction, currentTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: Translator) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -64,7 +63,7 @@ class ActionPauseResumeButton extends BaseComponentInteraction {
|
||||
interaction: MessageComponentInteraction,
|
||||
track: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseComponentParams, BaseComponentReturnType } from '../../types/intera
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class ActionPreviousButton extends BaseComponentInteraction {
|
||||
@@ -40,7 +39,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (history.tracks.data.length === 0) {
|
||||
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||
@@ -55,7 +54,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
private async handleNoTracksInHistory(
|
||||
logger: Logger,
|
||||
interaction: MessageComponentInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('No tracks in history.');
|
||||
return await interaction.reply({
|
||||
@@ -73,7 +72,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: Translator) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -92,7 +91,7 @@ class ActionPreviousButton extends BaseComponentInteraction {
|
||||
private async handleSuccess(
|
||||
interaction: MessageComponentInteraction,
|
||||
recoveredTrack: Track,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
|
||||
@@ -4,8 +4,7 @@ import { BaseComponentInteraction } from '../../common/classes/interactions';
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatModeDetailed } from '../../common/utils/formattingUtils';
|
||||
|
||||
class ActionSkipButton extends BaseComponentInteraction {
|
||||
@@ -39,7 +38,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
return await this.handleSuccess(interaction, skippedTrack, queue, translator);
|
||||
}
|
||||
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: TFunction) {
|
||||
private async handleAlreadySkipped(interaction: MessageComponentInteraction, translator: Translator) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -59,7 +58,7 @@ class ActionSkipButton extends BaseComponentInteraction {
|
||||
interaction: MessageComponentInteraction,
|
||||
skippedTrack: Track,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setAuthor(this.getEmbedUserAuthor(interaction))
|
||||
|
||||
@@ -12,8 +12,7 @@ import {
|
||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||
@@ -83,7 +82,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
this.addFfmpegNormalizerIfRequired(selectMenuInteraction);
|
||||
this.toggleFfmpegFilters(selectMenuInteraction, queue, logger);
|
||||
@@ -97,7 +96,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
this.toggleBiquadFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
@@ -110,7 +109,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
queue: GuildQueue,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
this.toggleEqualizerFilter(selectMenuInteraction, queue, logger);
|
||||
|
||||
@@ -197,7 +196,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return interaction.reply({
|
||||
@@ -209,7 +208,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
private buildSuccessEmbed(
|
||||
selectMenuInteraction: StringSelectMenuInteraction,
|
||||
filterType: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): EmbedBuilder {
|
||||
const availableFilters: FilterOption[] = this.getAvailableFilters(filterType);
|
||||
const enabledFilters: string = this.getEnabledFilters(selectMenuInteraction, availableFilters);
|
||||
@@ -276,7 +275,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||
private async replyWithDisabledFiltersEmbed(
|
||||
logger: Logger,
|
||||
interaction: StringSelectMenuInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.reply({
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkHistoryExists, checkQueueCurrentTrack } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class BackCommand extends BaseSlashCommandInteraction {
|
||||
@@ -47,7 +46,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory,
|
||||
backtoTrackPosition: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (backtoTrackPosition > history.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanHistoryLength(
|
||||
@@ -70,7 +69,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
history: GuildQueueHistory,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Specified track position was higher than total tracks.');
|
||||
return await interaction.reply({
|
||||
@@ -94,7 +93,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (history.tracks.data.length === 0) {
|
||||
return await this.handleNoTracksInHistory(logger, interaction, translator);
|
||||
@@ -109,7 +108,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
private async handleNoTracksInHistory(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('No tracks in history.');
|
||||
return await interaction.reply({
|
||||
@@ -130,7 +129,7 @@ class BackCommand extends BaseSlashCommandInteraction {
|
||||
private async respondWithSuccessEmbed(
|
||||
recoveredTrack: Track,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
|
||||
@@ -26,8 +26,7 @@ import {
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||
const biquadFilterOptions: BiquadFilterOptions = config.get('biquadFilterOptions');
|
||||
@@ -89,7 +88,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue<unknown>,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling ffmpeg filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
@@ -118,7 +117,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue<unknown>,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling biquad filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
@@ -145,7 +144,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
private async handleEqualizerFilters(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Handling biquad filters.');
|
||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||
@@ -169,7 +168,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
filterProvider: string,
|
||||
filterOptions: StringSelectMenuOptionBuilder[],
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
const actionRows = this.buildFilterActionRows(filterOptions, filterProvider, translator);
|
||||
|
||||
@@ -191,7 +190,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
private buildFilterActionRows(
|
||||
filterOptions: StringSelectMenuOptionBuilder[],
|
||||
filterProvider: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): APIActionRowComponent<APIMessageActionRowComponent>[] {
|
||||
const filterSelect: APIStringSelectComponent = new StringSelectMenuBuilder()
|
||||
.setCustomId(`filters-select-menu_${filterProvider}`)
|
||||
@@ -232,7 +231,7 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||
queue.filters.ffmpeg.setFilters(false);
|
||||
|
||||
@@ -16,8 +16,7 @@ import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
|
||||
import { checkHistoryExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
@@ -83,7 +82,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
history: GuildQueueHistory,
|
||||
currentTrack: Track,
|
||||
historyTracksListString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('History exists with current track, gathering information.');
|
||||
|
||||
@@ -152,7 +151,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: Translator): string => {
|
||||
return queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
@@ -164,7 +163,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
history: GuildQueueHistory,
|
||||
historyTracksListString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('History exists but there is no current track.');
|
||||
|
||||
@@ -192,7 +191,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
pageIndex: number,
|
||||
totalPages: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Specified page was higher than total pages.');
|
||||
|
||||
@@ -222,7 +221,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
return Math.ceil(history.tracks.data.length / 10) || 1;
|
||||
}
|
||||
|
||||
private getHistoryTracksListString(history: GuildQueueHistory, pageIndex: number, translator: TFunction): string {
|
||||
private getHistoryTracksListString(history: GuildQueueHistory, pageIndex: number, translator: Translator): string {
|
||||
if (!history || history.tracks.data.length === 0) {
|
||||
return translator('commands.history.emptyHistory', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
@@ -240,7 +239,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
|
||||
private getDisplayFullFooterInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
history: GuildQueueHistory,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, history, translator);
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkInVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { checkVoicePermissionJoinAndTalk } from '../../common/validation/permissionValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
class JoinCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -92,7 +91,7 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
||||
|
||||
private async handleCouldNotConnect(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
@@ -111,7 +110,7 @@ class JoinCommand extends BaseSlashCommandInteraction {
|
||||
private async handleExisitingQueue(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
const connectedChannel = queue.dispatcher?.channel;
|
||||
const channelMention = connectedChannel?.id ? `<#${connectedChannel.id}>` : '<#0>';
|
||||
|
||||
@@ -11,8 +11,7 @@ import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatMode } from '../../common/utils/formattingUtils';
|
||||
|
||||
class LoopCommand extends BaseSlashCommandInteraction {
|
||||
@@ -73,7 +72,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
currentRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
logger.debug('No repeat mode was provided, responding with current repeat mode.');
|
||||
|
||||
@@ -100,7 +99,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
currentRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
|
||||
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
|
||||
@@ -126,7 +125,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
fromRepeatMode: QueueRepeatMode,
|
||||
toRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<InteractionResponse<boolean>> {
|
||||
const newRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
|
||||
@@ -152,7 +151,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
||||
private getChangedRepeatModeEmbedReply(
|
||||
fromRepeatMode: QueueRepeatMode,
|
||||
toRepeatMode: QueueRepeatMode,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): string {
|
||||
const fromRepeatModeEmbedName = formatRepeatMode(fromRepeatMode, translator);
|
||||
const toRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
|
||||
|
||||
@@ -6,8 +6,7 @@ import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -161,7 +160,7 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusSearchQuery: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Responding with warning embed.');
|
||||
return await interaction.editReply({
|
||||
@@ -182,7 +181,7 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusLyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Lyrics text too long, splitting into multiple messages.');
|
||||
const messageCount: number = Math.ceil(geniusLyricsResult.lyrics.length / 3800);
|
||||
@@ -218,7 +217,7 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
geniusLyricsResult: LyricsData,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Responding with info embed.');
|
||||
return await interaction.editReply({
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class MoveCommand extends BaseSlashCommandInteraction {
|
||||
@@ -52,7 +51,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
fromPosition: number,
|
||||
toPosition: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (fromPosition > queue.tracks.data.length || toPosition > queue.tracks.data.length) {
|
||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||
@@ -78,7 +77,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('One of the specified track positions was higher than total tracks.');
|
||||
return await interaction.reply({
|
||||
@@ -104,7 +103,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
fromPosition: number,
|
||||
toPosition: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
|
||||
@@ -14,8 +14,7 @@ import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../types/interactionTypes';
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatModeDetailed } from '../../common/utils/formattingUtils';
|
||||
|
||||
class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
@@ -114,7 +113,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayPlays(currentTrack: Track | undefined, translator: TFunction): string {
|
||||
private getDisplayPlays(currentTrack: Track | undefined, translator: Translator): string {
|
||||
const trackMetadata = currentTrack?.metadata as TrackMetadata;
|
||||
|
||||
return translator('commands.nowplaying.playCount', {
|
||||
@@ -122,7 +121,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayTrackAuthor(currentTrack: Track | undefined, translator: TFunction): string {
|
||||
private getDisplayTrackAuthor(currentTrack: Track | undefined, translator: Translator): string {
|
||||
let author = currentTrack?.author;
|
||||
if (!author || author === 'cdn.discordapp.com') {
|
||||
author = translator('musicPlayerCommon.unavailableAuthor');
|
||||
@@ -130,7 +129,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
return author;
|
||||
}
|
||||
|
||||
private getTrackSourceString(currentTrack: Track, translator: TFunction): string {
|
||||
private getTrackSourceString(currentTrack: Track, translator: Translator): string {
|
||||
const sourceStringsFormatted: Map<string, string> = new Map([
|
||||
['youtube', 'YouTube'],
|
||||
['soundcloud', 'SoundCloud'],
|
||||
@@ -156,20 +155,20 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
||||
return sourceIcons.get(currentTrack.raw.source!) ?? '';
|
||||
}
|
||||
|
||||
private getDisplayTrackSource(currentTrack: Track, translator: TFunction) {
|
||||
private getDisplayTrackSource(currentTrack: Track, translator: Translator) {
|
||||
const trackSource: string = this.getTrackSourceString(currentTrack, translator);
|
||||
const trackSourceIcon: string = this.getTrackSourceIcon(currentTrack) ?? '';
|
||||
|
||||
return `**${trackSourceIcon} [${trackSource}](${currentTrack.raw.url ?? currentTrack.url})**`;
|
||||
}
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: Translator): string => {
|
||||
return queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
};
|
||||
|
||||
private getEmbedFields = (currentTrack: Track, translator: TFunction): EmbedField[] => {
|
||||
private getEmbedFields = (currentTrack: Track, translator: Translator): EmbedField[] => {
|
||||
const fields: EmbedField[] = [
|
||||
{
|
||||
name: translator('commands.nowplaying.embedFields.author'),
|
||||
|
||||
@@ -13,8 +13,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkVoicePermissionJoinAndTalk } from '../../common/validation/permissionValidator';
|
||||
import { transformQuery } from '../../common/validation/searchQueryValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class PlayCommand extends BaseSlashCommandInteraction {
|
||||
@@ -159,7 +158,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
searchResult: SearchResult,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Result found and added with player.play(), added to queue.');
|
||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||
@@ -219,7 +218,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
});
|
||||
}
|
||||
|
||||
private getDisplayFooterTrackPosition(position: number, translator: TFunction): EmbedFooterData {
|
||||
private getDisplayFooterTrackPosition(position: number, translator: Translator): EmbedFooterData {
|
||||
const fullFooterData = {
|
||||
text: translator('commands.play.footerAddedPosition', {
|
||||
position: position
|
||||
@@ -233,7 +232,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
transformedQuery: string,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug(`No results found for query: '${transformedQuery}'`);
|
||||
|
||||
@@ -256,7 +255,7 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
||||
query: string,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
logger: Logger,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug(`Playlist found but would exceed max queue size. Query: '${query}'.`);
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { formatDuration, formatRepeatModeDetailed, formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
class QueueCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -73,7 +72,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
currentTrack: Track,
|
||||
queueTracksListString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Queue exists with current track, gathering information.');
|
||||
|
||||
@@ -144,7 +143,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: TFunction): string => {
|
||||
private getDisplayTrackPlayingStatus = (queue: GuildQueue, translator: Translator): string => {
|
||||
return queue.node.isPaused()
|
||||
? translator('musicPlayerCommon.nowPausedTitle', { icon: this.embedOptions.icons.paused })
|
||||
: translator('musicPlayerCommon.nowPlayingTitle', { icon: this.embedOptions.icons.audioPlaying });
|
||||
@@ -155,7 +154,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
queueTracksListString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Queue exists but there is no current track.');
|
||||
|
||||
@@ -183,7 +182,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
pageIndex: number,
|
||||
totalPages: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Specified page was higher than total pages.');
|
||||
|
||||
@@ -213,7 +212,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
return Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||
}
|
||||
|
||||
private getQueueTracksListString(queue: GuildQueue, pageIndex: number, translator: TFunction): string {
|
||||
private getQueueTracksListString(queue: GuildQueue, pageIndex: number, translator: Translator): string {
|
||||
if (!queue || queue.tracks.data.length === 0) {
|
||||
return translator('commands.queue.emptyQueue', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
@@ -228,7 +227,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
private getDisplayQueueTotalDuration(queue: GuildQueue, translator: TFunction): string {
|
||||
private getDisplayQueueTotalDuration(queue: GuildQueue, translator: Translator): string {
|
||||
if (queue.tracks.data.length > 1000) {
|
||||
return translator('commands.queue.estimatedReallyLongTime', {
|
||||
playCommand: formatSlashCommand('play', translator)
|
||||
@@ -254,7 +253,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
||||
private getDisplayFullFooterInfo(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): EmbedFooterData {
|
||||
const pagination = this.getFooterDisplayPageInfo(interaction, queue, translator);
|
||||
const totalDuration = this.getDisplayQueueTotalDuration(queue, translator);
|
||||
|
||||
@@ -10,8 +10,7 @@ import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
|
||||
import { ExtendedClient } from '../../types/clientTypes';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
|
||||
import { checkValidGuildId } from '../../common/validation/systemCommandValidator';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -55,7 +54,7 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
executionId: string,
|
||||
error: Error | unknown,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.error(error, 'Failed to reload interaction module across shards.');
|
||||
|
||||
@@ -78,7 +77,7 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
client: ExtendedClient,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const commands = this.getCommands(client);
|
||||
const embedDescription = this.buildEmbedDescription(commands, translator);
|
||||
@@ -110,7 +109,7 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
||||
return params;
|
||||
}
|
||||
|
||||
private buildEmbedDescription(commands: string[] | undefined, translator: TFunction): string {
|
||||
private buildEmbedDescription(commands: string[] | undefined, translator: Translator): string {
|
||||
return (
|
||||
translator('commands.reload.reloadedCommands', {
|
||||
icon: this.embedOptions.icons.bot
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
@@ -69,7 +68,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const targetUser = interaction.options.getUser('target')!;
|
||||
const removedTracks: Track[] = [];
|
||||
@@ -95,7 +94,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const removedTracks: Track[] = [];
|
||||
const uniqueTrackUrls = new Set<string>();
|
||||
@@ -123,7 +122,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const start: number = interaction.options.getInteger('start')!;
|
||||
const end: number = interaction.options.getInteger('end')!;
|
||||
@@ -173,7 +172,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const queueLength = queue.tracks.data.length;
|
||||
queue.clear();
|
||||
@@ -191,7 +190,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const trackPositionInput: number = interaction.options.getInteger('position')!;
|
||||
|
||||
@@ -230,7 +229,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
private async handleNoTracksRemoved(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Responding with warning embed.');
|
||||
await interaction.reply({
|
||||
@@ -253,7 +252,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
removedAmount: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Responding with success embed.');
|
||||
await interaction.reply({
|
||||
@@ -277,7 +276,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
trackPositionInput: number,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Specified track position is higher than total tracks.');
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class SeekCommand extends BaseSlashCommandInteraction {
|
||||
@@ -70,7 +69,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Invalid duration format input.');
|
||||
|
||||
@@ -96,7 +95,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
durationInMilliseconds: number,
|
||||
formattedDurationString: string,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
queue.node.seek(durationInMilliseconds);
|
||||
logger.debug(`Seeked to '${formattedDurationString}' in current track.`);
|
||||
@@ -123,7 +122,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
formattedDurationString: string,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
): Promise<Message> {
|
||||
logger.debug('Duration specified is longer than the track duration.');
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/utils/formattingUtils';
|
||||
|
||||
class SkipCommand extends BaseSlashCommandInteraction {
|
||||
@@ -47,7 +46,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
trackPosition: number,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (trackPosition > queue.tracks.data.length) {
|
||||
return await this.handleTrackPositionHigherThanQueueLength(
|
||||
@@ -70,7 +69,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('Specified track position was higher than total tracks.');
|
||||
return await interaction.reply({
|
||||
@@ -94,7 +93,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
if (queue.tracks.data.length === 0 && !queue.currentTrack) {
|
||||
return await this.handleNoTracksInQueueAndNoCurrentTrack(logger, interaction, translator);
|
||||
@@ -109,7 +108,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
private async handleNoTracksInQueueAndNoCurrentTrack(
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
logger.debug('No tracks in queue and no current track.');
|
||||
return await interaction.reply({
|
||||
@@ -131,7 +130,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
||||
skippedTrack: Track,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
queue: GuildQueue,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
return await interaction.reply({
|
||||
embeds: [
|
||||
|
||||
@@ -5,8 +5,7 @@ import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/
|
||||
import { checkQueueExists } from '../../common/validation/queueValidator';
|
||||
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
|
||||
import { Logger } from '../../common/services/logger';
|
||||
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
|
||||
import { TFunction } from 'i18next';
|
||||
import { localizeCommand, useServerTranslator, Translator } from '../../common/utils/localeUtil';
|
||||
|
||||
class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
@@ -47,7 +46,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
const currentVolume: number = queue.node.volume;
|
||||
logger.debug('No volume input was provided, showing current volume.');
|
||||
@@ -75,7 +74,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
||||
queue: GuildQueue,
|
||||
logger: Logger,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
translator: TFunction
|
||||
translator: Translator
|
||||
) {
|
||||
queue.node.setVolume(volume);
|
||||
logger.debug(`Set volume to ${volume}%.`);
|
||||
|
||||
Reference in new issue
Block a user