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:
@@ -1,8 +1,9 @@
|
||||
import { moderationQueue } from '../../queues.js';
|
||||
import type { BotContext } from '../../types.js';
|
||||
import { PermissionFlagsBits, type ChatInputCommandInteraction } from 'discord.js';
|
||||
import type { Prisma } from '@prisma/client';
|
||||
import { buildCaseMetadata, type CaseAuditSource, t, type Locale } from '@nexumi/shared';
|
||||
import { safeRemoveBullJob } from '../../lib/safe-remove-job.js';
|
||||
import { moderationQueue } from '../../queues.js';
|
||||
import type { BotContext } from '../../types.js';
|
||||
import { MAX_TIMEOUT_MS } from './duration.js';
|
||||
|
||||
type CreateCaseInput = {
|
||||
@@ -96,9 +97,7 @@ export async function scheduleTempBanExpire(
|
||||
) {
|
||||
const jobId = tempBanJobId(guildId, userId);
|
||||
const existing = await moderationQueue.getJob(jobId);
|
||||
if (existing) {
|
||||
await existing.remove();
|
||||
}
|
||||
await safeRemoveBullJob(existing, { label: 'tempBanExpire', jobId });
|
||||
|
||||
await moderationQueue.add(
|
||||
'tempBanExpire',
|
||||
|
||||
Reference in New Issue
Block a user