Add suggestion status update job and queue integration
- Introduced a new `SuggestionStatusUpdateJob` type and corresponding worker to handle suggestion status updates in the bot's job processing. - Added `suggestionsQueue` and `suggestionsQueueEvents` for managing suggestion-related jobs in both the bot and WebUI. - Implemented `runSuggestionStatusUpdateJob` to facilitate staff actions on suggestions via the WebUI, ensuring consistent behavior with existing commands. - Enhanced error handling for suggestion actions to improve user experience and reliability.
This commit is contained in:
@@ -12,13 +12,16 @@ import { redis } from './redis';
|
||||
export const giveawayQueueName = 'giveaways';
|
||||
export const scheduleQueueName = 'schedules';
|
||||
export const guildBackupQueueName = 'guild-backups';
|
||||
export const suggestionsQueueName = 'suggestions';
|
||||
|
||||
const globalForQueues = globalThis as unknown as {
|
||||
__nexumiGiveawayQueue?: Queue;
|
||||
__nexumiScheduleQueue?: Queue;
|
||||
__nexumiGuildBackupQueue?: Queue;
|
||||
__nexumiSuggestionsQueue?: Queue;
|
||||
__nexumiGiveawayQueueEvents?: QueueEvents;
|
||||
__nexumiGuildBackupQueueEvents?: QueueEvents;
|
||||
__nexumiSuggestionsQueueEvents?: QueueEvents;
|
||||
};
|
||||
|
||||
export const giveawayQueue: Queue =
|
||||
@@ -30,6 +33,9 @@ export const scheduleQueue: Queue =
|
||||
export const guildBackupQueue: Queue =
|
||||
globalForQueues.__nexumiGuildBackupQueue ?? new Queue(guildBackupQueueName, { connection: redis });
|
||||
|
||||
export const suggestionsQueue: Queue =
|
||||
globalForQueues.__nexumiSuggestionsQueue ?? new Queue(suggestionsQueueName, { connection: redis });
|
||||
|
||||
/**
|
||||
* QueueEvents instances are only needed for jobs where the dashboard needs
|
||||
* to wait for the bot to finish (e.g. ending a giveaway so the winners list
|
||||
@@ -44,11 +50,17 @@ export const guildBackupQueueEvents: QueueEvents =
|
||||
globalForQueues.__nexumiGuildBackupQueueEvents ??
|
||||
new QueueEvents(guildBackupQueueName, { connection: redis.duplicate() });
|
||||
|
||||
export const suggestionsQueueEvents: QueueEvents =
|
||||
globalForQueues.__nexumiSuggestionsQueueEvents ??
|
||||
new QueueEvents(suggestionsQueueName, { connection: redis.duplicate() });
|
||||
|
||||
globalForQueues.__nexumiGiveawayQueue = giveawayQueue;
|
||||
globalForQueues.__nexumiScheduleQueue = scheduleQueue;
|
||||
globalForQueues.__nexumiGuildBackupQueue = guildBackupQueue;
|
||||
globalForQueues.__nexumiSuggestionsQueue = suggestionsQueue;
|
||||
globalForQueues.__nexumiGiveawayQueueEvents = giveawayQueueEvents;
|
||||
globalForQueues.__nexumiGuildBackupQueueEvents = guildBackupQueueEvents;
|
||||
globalForQueues.__nexumiSuggestionsQueueEvents = suggestionsQueueEvents;
|
||||
|
||||
const DEFAULT_WAIT_TIMEOUT_MS = 15_000;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user