Implement leveling and economy features with associated models and commands
- Added new models for leveling and economy functionalities in the Prisma schema, including LevelingConfig, MemberLevel, LevelReward, EconomyConfig, MemberEconomy, ShopItem, and InventoryItem. - Introduced commands for managing XP, economy transactions, and shop interactions, enhancing user engagement. - Updated job handling to include reminders and poll closing functionalities. - Enhanced localization support for new commands and features in both German and English. - Improved the bot's job processing capabilities with a dedicated reminder worker for scheduled tasks.
This commit is contained in:
@@ -9,12 +9,16 @@ import type { BotContext } from './types.js';
|
||||
import { env } from './env.js';
|
||||
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 {
|
||||
automodQueue,
|
||||
automodQueueName,
|
||||
backupQueue,
|
||||
backupQueueName,
|
||||
moderationQueueName,
|
||||
reminderQueue,
|
||||
reminderQueueName,
|
||||
verificationQueueName
|
||||
} from './queues.js';
|
||||
|
||||
@@ -23,6 +27,7 @@ export {
|
||||
backupQueue,
|
||||
moderationQueue,
|
||||
moderationQueueName,
|
||||
reminderQueue,
|
||||
verificationQueue
|
||||
} from './queues.js';
|
||||
|
||||
@@ -37,6 +42,14 @@ type VerificationCompleteJob = {
|
||||
userId: string;
|
||||
};
|
||||
|
||||
type ReminderSendJob = {
|
||||
reminderId: string;
|
||||
};
|
||||
|
||||
type PollCloseJob = {
|
||||
pollId: string;
|
||||
};
|
||||
|
||||
export function startWorkers(context: BotContext): Worker[] {
|
||||
const moderationWorker = new Worker<TempBanJob>(
|
||||
moderationQueueName,
|
||||
@@ -105,7 +118,25 @@ export function startWorkers(context: BotContext): Worker[] {
|
||||
logger.error({ jobId: job?.id, error }, 'Verification job failed');
|
||||
});
|
||||
|
||||
return [moderationWorker, backupWorker, automodWorker, verificationWorker];
|
||||
const reminderWorker = new Worker<ReminderSendJob | PollCloseJob>(
|
||||
reminderQueueName,
|
||||
async (job) => {
|
||||
if (job.name === 'reminderSend') {
|
||||
await sendReminder(context, (job.data as ReminderSendJob).reminderId);
|
||||
return;
|
||||
}
|
||||
if (job.name === 'pollClose') {
|
||||
await closePoll(context, (job.data as PollCloseJob).pollId);
|
||||
}
|
||||
},
|
||||
{ connection: redis }
|
||||
);
|
||||
|
||||
reminderWorker.on('failed', (job, error) => {
|
||||
logger.error({ jobId: job?.id, error }, 'Reminder job failed');
|
||||
});
|
||||
|
||||
return [moderationWorker, backupWorker, automodWorker, verificationWorker, reminderWorker];
|
||||
}
|
||||
|
||||
export async function ensureRecurringJobs(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user