Move deferring into the specific interactions where required. Makes especially validation warnings ephemeral.

This commit is contained in:
Marius Begby committed 2024-01-30 19:21:42 +01:00
1 parent a7aefd085f
commit f3329fceee
36 files changed
+164 -175

No files matched your search

+7 -5
View File
@@ -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))
@@ -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) {
+1 -1
View File
@@ -64,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(
+7 -5
View File
@@ -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();
}
+3
View File
@@ -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) {
+3
View File
@@ -26,6 +26,9 @@ class LeaveCommand extends BaseSlashCommandInteraction {
checkQueueExists
]);
await interaction.deferReply();
logger.debug('Interaction deferred.');
logger.debug('Deleting queue.');
this.deleteQueue(queue);
+9 -8
View File
@@ -2,7 +2,7 @@ import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
import {
ChatInputCommandInteraction,
EmbedBuilder,
Message,
InteractionResponse,
SlashCommandBuilder,
SlashCommandIntegerOption
} from 'discord.js';
@@ -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))
+3
View File
@@ -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),
+4 -3
View File
@@ -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))
+1 -1
View File
@@ -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))
+1 -1
View File
@@ -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))
+3
View File
@@ -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 });
+7 -5
View File
@@ -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();
}
+3
View File
@@ -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) {
+11 -8
View File
@@ -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();
}
+3
View File
@@ -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);
@@ -42,6 +42,9 @@ class SettingsCommand extends BaseSlashCommandInteraction {
const logger = this.getLogger(this.name, executionId, interaction);
const translator = useServerTranslator(interaction);
await interaction.deferReply();
logger.debug('Interaction deferred.');
const subcommand = interaction.options.getSubcommand();
switch (subcommand) {
+3
View File
@@ -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,
+1 -1
View File
@@ -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))
+7 -5
View File
@@ -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))
+3
View File
@@ -31,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),
+1 -1
View File
@@ -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))
@@ -26,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),
+3
View File
@@ -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) {