Add giveaway, ticket, self-role, starboard, and suggestion features to the bot
- Introduced new models in the Prisma schema for giveaways, tickets, self-role panels, starboard configurations, and suggestions, enhancing the bot's functionality. - Implemented job handling for self-role expiration and ticket management, improving user experience. - Updated command localization to support new features in both German and English. - Enhanced the job processing system to include dedicated workers for managing tickets and self-role expirations. - Documented the new features and their setup processes in PHASE-TRACKING.md for clarity on implementation steps.
This commit is contained in:
@@ -11,6 +11,7 @@ import { refreshPhishingDomains } from './modules/automod/filters.js';
|
||||
import { completeVerification } from './modules/verification/handlers.js';
|
||||
import { closePoll } from './modules/utility/poll.js';
|
||||
import { sendReminder } from './modules/utility/reminders.js';
|
||||
import { expireSelfRole } from './modules/selfroles/service.js';
|
||||
import {
|
||||
automodQueue,
|
||||
automodQueueName,
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
backupQueueName,
|
||||
moderationQueueName,
|
||||
reminderQueueName,
|
||||
ticketQueueName,
|
||||
verificationQueueName
|
||||
} from './queues.js';
|
||||
|
||||
@@ -49,6 +51,12 @@ type PollCloseJob = {
|
||||
pollId: string;
|
||||
};
|
||||
|
||||
type SelfRoleExpireJob = {
|
||||
guildId: string;
|
||||
userId: string;
|
||||
roleId: string;
|
||||
};
|
||||
|
||||
export function startWorkers(context: BotContext): Worker[] {
|
||||
const moderationWorker = new Worker<TempBanJob>(
|
||||
moderationQueueName,
|
||||
@@ -135,7 +143,22 @@ export function startWorkers(context: BotContext): Worker[] {
|
||||
logger.error({ jobId: job?.id, error }, 'Reminder job failed');
|
||||
});
|
||||
|
||||
return [moderationWorker, backupWorker, automodWorker, verificationWorker, reminderWorker];
|
||||
const ticketWorker = new Worker<SelfRoleExpireJob>(
|
||||
ticketQueueName,
|
||||
async (job) => {
|
||||
if (job.name !== 'selfRoleExpire') {
|
||||
return;
|
||||
}
|
||||
await expireSelfRole(context, job.data.guildId, job.data.userId, job.data.roleId);
|
||||
},
|
||||
{ connection: redis }
|
||||
);
|
||||
|
||||
ticketWorker.on('failed', (job, error) => {
|
||||
logger.error({ jobId: job?.id, error }, 'Ticket queue job failed');
|
||||
});
|
||||
|
||||
return [moderationWorker, backupWorker, automodWorker, verificationWorker, reminderWorker, ticketWorker];
|
||||
}
|
||||
|
||||
export async function ensureRecurringJobs(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user