feat!: Extracted handling of interactions into separate files

This commit is contained in:
Marius Begby committed 2023-08-28 17:21:52 +02:00
1 parent 8e9cb308e9
commit 780e20d419
7 files changed
+166 -153

No files matched your search

@@ -0,0 +1,24 @@
import { MessageComponentInteraction } from 'discord.js';
import loggerModule from '../services/logger';
const logger = loggerModule.child({
source: 'interactionComponentHandler.js',
module: 'handler',
name: 'interactionComponentHandler'
});
export const handleComponent = async (interaction: MessageComponentInteraction, executionId: string) => {
await interaction.deferReply();
logger.debug('Interaction deferred.');
const componentId = interaction.customId.split('_')[0];
const referenceId = interaction.customId.split('_')[1];
logger.debug(`Parsed componentId: ${componentId}`);
const componentModule = await import(`../interactions/components/${componentId}.js`);
const { default: component } = componentModule;
logger.debug('Executing component interaction.');
await component.execute({ interaction, referenceId, executionId });
};