mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 14:38:49 +00:00
feat!: Extracted handling of interactions into separate files
This commit is contained in:
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 });
|
||||
};
|
||||
Reference in new issue
Block a user