Implement command cooldown management and enhance command execution flow
- Introduced `applyCommandCooldown` function to manage per-command cooldowns after execution, improving command rate limiting. - Updated command execution flow to include cooldown application, ensuring users are informed of cooldown status. - Enhanced error handling in interaction replies, allowing for more graceful error management and user feedback. - Improved the handling of interaction responses across various commands, ensuring consistent user experience. - Added permission checks for new commands, ensuring only authorized users can execute specific actions.
This commit is contained in:
@@ -48,7 +48,7 @@ async function ensureMod(
|
||||
await interaction.reply({ content: t(locale, 'generic.guildOnly'), ephemeral: true });
|
||||
return false;
|
||||
}
|
||||
return requirePermission(interaction, permission, locale);
|
||||
return requirePermission(interaction, permission, locale, { botPermissions: permission });
|
||||
}
|
||||
|
||||
async function replySuccessCase(
|
||||
@@ -56,8 +56,13 @@ async function replySuccessCase(
|
||||
locale: 'de' | 'en',
|
||||
caseNumber: number
|
||||
): Promise<void> {
|
||||
const content = tf(locale, 'moderation.success.case', { caseNumber });
|
||||
if (interaction.deferred || interaction.replied) {
|
||||
await interaction.editReply({ content });
|
||||
return;
|
||||
}
|
||||
await interaction.reply({
|
||||
content: tf(locale, 'moderation.success.case', { caseNumber }),
|
||||
content,
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
@@ -460,6 +465,7 @@ const lockCommand: SlashCommand = {
|
||||
const guild = interaction.guild!;
|
||||
|
||||
if (serverWide) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
for (const channel of guild.channels.cache.values()) {
|
||||
if (channel.type !== ChannelType.GuildText && channel.type !== ChannelType.GuildAnnouncement) {
|
||||
continue;
|
||||
@@ -495,6 +501,7 @@ const unlockCommand: SlashCommand = {
|
||||
const guild = interaction.guild!;
|
||||
|
||||
if (serverWide) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
for (const channel of guild.channels.cache.values()) {
|
||||
if (channel.type !== ChannelType.GuildText && channel.type !== ChannelType.GuildAnnouncement) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user