Enhance bot command handling with new leveling, economy, and utility features

- Integrated leveling and economy commands, including XP management and shop interactions.
- Added context menu support for utility commands, improving user interaction options.
- Updated command registration to include new commands and context menus, enhancing overall functionality.
- Improved logging to track the registration of commands and context menus.
- Refactored interaction handling to accommodate new command types and ensure smooth execution.
This commit is contained in:
smueller
2026-07-22 12:56:00 +02:00
parent fa5910ec43
commit 58623bd1d3
8 changed files with 140 additions and 43 deletions

View File

@@ -10,7 +10,7 @@ import { env } from './env.js';
import { logger } from './logger.js';
import { prisma } from './db.js';
import { redis } from './redis.js';
import { registerCommands, routeCommand } from './commands.js';
import { registerCommands, routeCommand, routeContextMenu } from './commands.js';
import { ensureRecurringJobs, startWorkers } from './jobs.js';
import type { BotContext } from './types.js';
import { startHealthServer } from './health.js';
@@ -26,6 +26,19 @@ import { registerWelcomeEvents } from './modules/welcome/events.js';
import { registerVerificationEvents } from './modules/verification/events.js';
import { handleVerificationButton } from './modules/verification/handlers.js';
import { isVerificationButton } from './modules/verification/service.js';
import { registerLevelingEvents } from './modules/leveling/events.js';
import {
handleBlackjackButton,
isBlackjackButton
} from './modules/economy/blackjack-buttons.js';
import {
handleEmbedModal,
handlePollButton,
isEmbedModal,
isPollButton,
registerUtilityEvents
} from './modules/utility/index.js';
import { handleFunButton, isFunButton } from './modules/fun/index.js';
const isShard = process.argv.includes('--shard');
@@ -59,6 +72,8 @@ if (!isShard) {
registerLoggingEvents(context);
registerWelcomeEvents(context);
registerVerificationEvents(context);
registerLevelingEvents(context);
registerUtilityEvents(context);
client.on(Events.ClientReady, async () => {
logger.info({ tag: client.user?.tag }, 'Bot ready');
@@ -80,6 +95,11 @@ if (!isShard) {
return;
}
if (interaction.isMessageContextMenuCommand()) {
await routeContextMenu(interaction, context);
return;
}
if (interaction.isButton() && isModerationConfirmation(interaction.customId)) {
await handleModerationConfirmation(interaction, context);
return;
@@ -89,6 +109,26 @@ if (!isShard) {
await handleVerificationButton(interaction, context);
return;
}
if (interaction.isButton() && isBlackjackButton(interaction.customId)) {
await handleBlackjackButton(interaction, context);
return;
}
if (interaction.isButton() && isPollButton(interaction.customId)) {
await handlePollButton(interaction, context);
return;
}
if (interaction.isButton() && isFunButton(interaction.customId)) {
await handleFunButton(interaction, context);
return;
}
if (interaction.isModalSubmit() && isEmbedModal(interaction.customId)) {
await handleEmbedModal(interaction, context);
return;
}
} catch (error) {
logger.error({ error }, 'Interaction handling failed');
const locale = await getGuildLocale(context.prisma, interaction.guildId);