Merge pull request #374 from mariusbegby/v6-release

V6 release
This commit is contained in:
Marius Begby authored and GitHub committed 2024-02-03 11:06:53 +01:00
commit 8c18480357
88 files changed
+651 -486

No files matched your search

+12 -10
View File
@@ -1,13 +1,13 @@
import { GuildQueue, GuildQueueHistory, Track, useHistory, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkHistoryExists, checkQueueCurrentTrack } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkHistoryExists, checkQueueCurrentTrack } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
import { formatSlashCommand } from '../../common/formattingUtils';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class BackCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -73,7 +73,7 @@ class BackCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('Specified track position was higher than total tracks.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -85,7 +85,8 @@ class BackCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -111,7 +112,7 @@ class BackCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('No tracks in history.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -121,7 +122,8 @@ class BackCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -130,7 +132,7 @@ class BackCommand extends BaseSlashCommandInteraction {
interaction: ChatInputCommandInteraction,
translator: TFunction
) {
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+7 -4
View File
@@ -16,7 +16,7 @@ import {
StringSelectMenuOptionBuilder
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import {
BiquadFilterOptions,
EqualizerFilterOptions,
@@ -24,9 +24,9 @@ import {
FilterOption
} from '../../types/configTypes';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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';
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
@@ -68,6 +68,9 @@ class FiltersCommand extends BaseSlashCommandInteraction {
checkQueueCurrentTrack
]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const filterProvider: string = interaction.options.getString('type') || 'ffmpeg';
switch (filterProvider) {
+9 -4
View File
@@ -13,9 +13,14 @@ import {
SlashCommandNumberOption,
SlashCommandStringOption
} from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { CommandMetadata, localizeCommand, translatorInstance, useServerTranslator } from '../../common/localeUtil';
import {
CommandMetadata,
localizeCommand,
translatorInstance,
useServerTranslator
} from '../../common/utils/localeUtil';
import { ExtendedClient } from '../../types/clientTypes';
class HelpCommand extends BaseSlashCommandInteraction {
@@ -59,7 +64,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
};
logger.debug('Responding with info embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -117,7 +122,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
}`;
}
private getCommandParams(command: BaseSlashCommandInteraction, locale: LocaleString): string {
public getCommandParams(command: BaseSlashCommandInteraction, locale: LocaleString): string {
const commandName = command.data.name;
const option = command.data.options[0];
+12 -10
View File
@@ -12,13 +12,13 @@ import {
SlashCommandBuilder
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkHistoryExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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 { formatRepeatModeDetailed, formatSlashCommand } from '../../common/formattingUtils';
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/utils/formattingUtils';
class HistoryCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -125,7 +125,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
};
logger.debug('Responding with info embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
@@ -169,7 +169,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
logger.debug('History exists but there is no current track.');
logger.debug('Responding with info embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
@@ -182,7 +182,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
)
.setFooter(this.getDisplayFullFooterInfo(interaction, history, translator))
.setColor(this.embedOptions.colors.info)
]
],
ephemeral: true
});
}
@@ -196,7 +197,7 @@ class HistoryCommand extends BaseSlashCommandInteraction {
logger.debug('Specified page was higher than total pages.');
logger.debug('Responding with warning embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -207,7 +208,8 @@ class HistoryCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
return Promise.resolve();
}
+8 -5
View File
@@ -1,12 +1,12 @@
import { GuildQueue, useMainPlayer, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, GuildMember, Message, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkVoicePermissionJoinAndTalk } from '../../utils/validation/permissionValidator';
import { checkInVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { checkVoicePermissionJoinAndTalk } from '../../common/validation/permissionValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { formatSlashCommand } from '../../common/formattingUtils';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
import { TFunction } from 'i18next';
class JoinCommand extends BaseSlashCommandInteraction {
@@ -22,6 +22,9 @@ class JoinCommand extends BaseSlashCommandInteraction {
await this.runValidators({ interaction, executionId }, [checkInVoiceChannel, checkVoicePermissionJoinAndTalk]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const existingQueue = useQueue(interaction.guild!.id);
if (existingQueue) {
+8 -5
View File
@@ -1,11 +1,11 @@
import { GuildQueue, useQueue } from 'discord-player';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { formatSlashCommand } from '../../common/formattingUtils';
import { checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class LeaveCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -26,6 +26,9 @@ class LeaveCommand extends BaseSlashCommandInteraction {
checkQueueExists
]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
logger.debug('Deleting queue.');
this.deleteQueue(queue);
+14 -13
View File
@@ -2,18 +2,18 @@ import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
import {
ChatInputCommandInteraction,
EmbedBuilder,
Message,
InteractionResponse,
SlashCommandBuilder,
SlashCommandIntegerOption
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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 { formatRepeatMode } from '../../common/formattingUtils';
import { formatRepeatMode } from '../../common/utils/formattingUtils';
class LoopCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -74,7 +74,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
interaction: ChatInputCommandInteraction,
currentRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
): Promise<InteractionResponse<boolean>> {
logger.debug('No repeat mode was provided, responding with current repeat mode.');
const repeatModeEmbedIcon =
@@ -82,7 +82,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
logger.debug('Responding with info embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -101,11 +101,11 @@ class LoopCommand extends BaseSlashCommandInteraction {
interaction: ChatInputCommandInteraction,
currentRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
): Promise<InteractionResponse<boolean>> {
const repeatModeEmbedName = formatRepeatMode(currentRepeatMode, translator);
logger.debug(`Loop mode is already set to '${repeatModeEmbedName}'.`);
logger.debug('Responding with warning embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -115,7 +115,8 @@ class LoopCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -126,7 +127,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
fromRepeatMode: QueueRepeatMode,
toRepeatMode: QueueRepeatMode,
translator: TFunction
): Promise<Message> {
): Promise<InteractionResponse<boolean>> {
const newRepeatModeEmbedName = formatRepeatMode(toRepeatMode, translator);
const getChangedRepeatModeEmbedReply = this.getChangedRepeatModeEmbedReply(
fromRepeatMode,
@@ -138,7 +139,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
logger.debug(`Loop mode changed to '${newRepeatModeEmbedName}'.`);
logger.debug('Responding with success embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+7 -4
View File
@@ -2,11 +2,11 @@ import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
import { GuildQueue, Player, QueryType, SearchResult, Track, useMainPlayer, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, Message, SlashCommandBuilder } from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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';
class LyricsCommand extends BaseSlashCommandInteraction {
@@ -38,6 +38,9 @@ class LyricsCommand extends BaseSlashCommandInteraction {
]);
}
await interaction.deferReply();
logger.debug('Interaction deferred.');
const geniusSearchQuery: string = this.getGeniusSearchQuery(logger, query, queue);
const [playerSearchResult, geniusLyricsResult] = await Promise.all([
this.getPlayerSearchResult(logger, query),
+9 -8
View File
@@ -1,13 +1,13 @@
import { GuildQueue, Track, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
import { formatSlashCommand } from '../../common/formattingUtils';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class MoveCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -81,7 +81,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('One of the specified track positions was higher than total tracks.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -94,7 +94,8 @@ class MoveCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -105,7 +106,7 @@ class MoveCommand extends BaseSlashCommandInteraction {
toPosition: number,
translator: TFunction
) {
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+6 -6
View File
@@ -10,13 +10,13 @@ import {
EmbedField,
SlashCommandBuilder
} from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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 { formatRepeatModeDetailed } from '../../common/formattingUtils';
import { formatRepeatModeDetailed } from '../../common/utils/formattingUtils';
class NowPlayingCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -88,7 +88,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
};
logger.debug('Sending info embed with action row components.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
+5 -5
View File
@@ -1,11 +1,11 @@
import { GuildQueue, Track, useQueue } from 'discord-player';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
class PauseCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -32,7 +32,7 @@ class PauseCommand extends BaseSlashCommandInteraction {
this.togglePauseState(logger, queue);
logger.debug('Responding with success embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+11 -10
View File
@@ -8,14 +8,14 @@ import {
SlashCommandBuilder
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction, CustomError } from '../../classes/interactions';
import { BaseSlashCommandInteraction, CustomError } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkVoicePermissionJoinAndTalk } from '../../utils/validation/permissionValidator';
import { transformQuery } from '../../utils/validation/searchQueryValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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 { formatSlashCommand } from '../../common/formattingUtils';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class PlayCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -43,6 +43,9 @@ class PlayCommand extends BaseSlashCommandInteraction {
await this.runValidators({ interaction, executionId }, [checkVoicePermissionJoinAndTalk]);
}
await interaction.deferReply();
logger.debug('Interaction deferred.');
const player = useMainPlayer()!;
const searchQuery = interaction.options.getString('query')!;
const transformedQuery = transformQuery({ query: searchQuery, executionId });
@@ -185,10 +188,8 @@ class PlayCommand extends BaseSlashCommandInteraction {
count: searchResult.tracks.length,
queueCommand: formatSlashCommand('queue', translator)
});
if (queue.tracks.data.length != searchResult.tracks.length) {
const posistionFirstTrackInPlaylist = queue.tracks.data.length - searchResult.tracks.length + 1;
embedFooter = this.getDisplayFooterTrackPosition(posistionFirstTrackInPlaylist, translator);
}
const posistionFirstTrackInPlaylist = queue.tracks.data.length - searchResult.tracks.length + 1;
embedFooter = this.getDisplayFooterTrackPosition(posistionFirstTrackInPlaylist, translator);
} else if (queue.currentTrack === track && queue.tracks.data.length === 0) {
if (!this.embedOptions.behavior.enablePlayerStartMessages) {
message =
+12 -10
View File
@@ -12,12 +12,12 @@ import {
SlashCommandBuilder
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { formatDuration, formatRepeatModeDetailed, formatSlashCommand } from '../../common/formattingUtils';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
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';
class QueueCommand extends BaseSlashCommandInteraction {
@@ -115,7 +115,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
};
logger.debug('Responding with info embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
@@ -160,7 +160,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
logger.debug('Queue exists but there is no current track.');
logger.debug('Responding with info embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedQueueAuthor(interaction, queue, translator))
@@ -173,7 +173,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
)
.setFooter(this.getDisplayFullFooterInfo(interaction, queue, translator))
.setColor(this.embedOptions.colors.info)
]
],
ephemeral: true
});
}
@@ -187,7 +188,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
logger.debug('Specified page was higher than total pages.');
logger.debug('Responding with warning embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -198,7 +199,8 @@ class QueueCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
return Promise.resolve();
}
+6 -3
View File
@@ -6,11 +6,11 @@ import {
SlashCommandBuilder
} from 'discord.js';
import { Logger } from 'pino';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { ExtendedClient } from '../../types/clientTypes';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkValidGuildId } from '../../utils/validation/systemCommandValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { checkValidGuildId } from '../../common/validation/systemCommandValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
class ReloadCommand extends BaseSlashCommandInteraction {
@@ -27,6 +27,9 @@ class ReloadCommand extends BaseSlashCommandInteraction {
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
try {
await this.reloadInteractionsAcrossShards(logger, executionId, client!);
} catch (error) {
+16 -13
View File
@@ -1,13 +1,13 @@
import { GuildQueue, Track, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { TFunction } from 'i18next';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { formatSlashCommand } from '../../common/formattingUtils';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class RemoveCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -134,7 +134,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
logger.debug('Start position is higher than end position.');
logger.debug('Responding with warning embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -146,7 +146,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
return Promise.resolve();
}
@@ -208,7 +209,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
logger.debug(`Removed track '${removedTrack.url}' from queue.`);
logger.debug('Responding with success embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
@@ -232,7 +233,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('Responding with warning embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
@@ -242,7 +243,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
return Promise.resolve();
}
@@ -254,7 +256,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('Responding with success embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
@@ -280,7 +282,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
logger.debug('Specified track position is higher than total tracks.');
logger.debug('Responding with warning embed.');
await interaction.editReply({
await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -292,7 +294,8 @@ class RemoveCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
return Promise.resolve();
}
+8 -5
View File
@@ -1,13 +1,13 @@
import { GuildQueue, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, Message, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
import { formatSlashCommand } from '../../common/formattingUtils';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class SeekCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -33,6 +33,9 @@ class SeekCommand extends BaseSlashCommandInteraction {
checkQueueCurrentTrack
]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const durationInputSplit: string[] = interaction.options.getString('duration')!.split(':');
const formattedDurationString: string = this.parseDurationArray(durationInputSplit);
+6 -3
View File
@@ -5,12 +5,12 @@ import {
EmbedFooterData,
SlashCommandBuilder
} from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { ExtendedClient } from '../../types/clientTypes';
import { BaseSlashCommandParams, BaseSlashCommandReturnType, ShardInfo } from '../../types/interactionTypes';
import { checkValidGuildId } from '../../utils/validation/systemCommandValidator';
import { checkValidGuildId } from '../../common/validation/systemCommandValidator';
import { Logger } from 'pino';
import { localizeCommand } from '../../common/localeUtil';
import { localizeCommand } from '../../common/utils/localeUtil';
class ShardsCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -43,6 +43,9 @@ class ShardsCommand extends BaseSlashCommandInteraction {
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const shardInfoList: ShardInfo[] = await this.fetchShardInfo(
client!,
logger,
+6 -6
View File
@@ -1,11 +1,11 @@
import { GuildQueue, useQueue } from 'discord-player';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueEmpty, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { formatSlashCommand } from '../../common/formattingUtils';
import { checkQueueEmpty, checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class ShuffleCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -31,7 +31,7 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
logger.debug('Shuffled queue tracks.');
logger.debug('Responding with success embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+12 -10
View File
@@ -1,13 +1,13 @@
import { GuildQueue, Track, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkQueueCurrentTrack, checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/formattingUtils';
import { formatRepeatModeDetailed, formatSlashCommand } from '../../common/utils/formattingUtils';
class SkipCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -73,7 +73,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('Specified track position was higher than total tracks.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -85,7 +85,8 @@ class SkipCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -111,7 +112,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
translator: TFunction
) {
logger.debug('No tracks in queue and no current track.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(
@@ -121,7 +122,8 @@ class SkipCommand extends BaseSlashCommandInteraction {
})
)
.setColor(this.embedOptions.colors.warning)
]
],
ephemeral: true
});
}
@@ -131,7 +133,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
queue: GuildQueue,
translator: TFunction
) {
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+11 -3
View File
@@ -10,10 +10,15 @@ import {
EmbedBuilder,
SlashCommandBuilder
} from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../common/statusUtils';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import {
getBotStatistics,
getDiscordStatus,
getPlayerStatistics,
getSystemStatus
} from '../../common/utils/statusUtils';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
class StatusCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -26,6 +31,9 @@ class StatusCommand extends BaseSlashCommandInteraction {
const logger = this.getLogger(this.name, executionId, interaction);
const translator = useServerTranslator(interaction);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
getBotStatistics(client!, version, translator),
getPlayerStatistics(client!, translator),
+6 -6
View File
@@ -1,11 +1,11 @@
import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { formatSlashCommand } from '../../common/formattingUtils';
import { checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { formatSlashCommand } from '../../common/utils/formattingUtils';
class StopCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -33,7 +33,7 @@ class StopCommand extends BaseSlashCommandInteraction {
}
logger.debug('Responding with success embed.');
return await interaction.editReply({
return await interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor(this.getEmbedUserAuthor(interaction))
+12 -4
View File
@@ -1,11 +1,16 @@
// @ts-ignore
import { dependencies, version } from '../../../package.json';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { getBotStatistics, getDiscordStatus, getPlayerStatistics, getSystemStatus } from '../../common/statusUtils';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import {
getBotStatistics,
getDiscordStatus,
getPlayerStatistics,
getSystemStatus
} from '../../common/utils/statusUtils';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkValidGuildId } from '../../utils/validation/systemCommandValidator';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { checkValidGuildId } from '../../common/validation/systemCommandValidator';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
class SystemStatusCommand extends BaseSlashCommandInteraction {
constructor() {
@@ -21,6 +26,9 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
await this.runValidators({ interaction, executionId }, [checkValidGuildId]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const [botStatisticsEmbedString, playerStatisticsEmbedString, systemStatusEmbedString] = await Promise.all([
getBotStatistics(client!, version, translator),
getPlayerStatistics(client!, translator),
+7 -4
View File
@@ -1,11 +1,11 @@
import { GuildQueue, useQueue } from 'discord-player';
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { BaseSlashCommandInteraction } from '../../classes/interactions';
import { BaseSlashCommandInteraction } from '../../common/classes/interactions';
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../types/interactionTypes';
import { checkQueueExists } from '../../utils/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
import { checkQueueExists } from '../../common/validation/queueValidator';
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../common/validation/voiceChannelValidator';
import { Logger } from 'pino';
import { localizeCommand, useServerTranslator } from '../../common/localeUtil';
import { localizeCommand, useServerTranslator } from '../../common/utils/localeUtil';
import { TFunction } from 'i18next';
class VolumeCommand extends BaseSlashCommandInteraction {
@@ -31,6 +31,9 @@ class VolumeCommand extends BaseSlashCommandInteraction {
checkQueueExists
]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const volume: number = interaction.options.getInteger('percentage')!;
if (!volume && volume !== 0) {