diff --git a/src/handlers/interactionAutocompleteHandler.ts b/src/handlers/interactionAutocompleteHandler.ts index 1d70551..5ecdfc0 100644 --- a/src/handlers/interactionAutocompleteHandler.ts +++ b/src/handlers/interactionAutocompleteHandler.ts @@ -1,13 +1,14 @@ import { AutocompleteInteraction } from 'discord.js'; import loggerModule from '../services/logger'; -const logger = loggerModule.child({ - source: 'interactionCutocompleteHandler.ts', - module: 'handler', - name: 'interactionAutocompleteHandler' -}); - export const handleAutocomplete = async (interaction: AutocompleteInteraction, executionId: string) => { + const logger = loggerModule.child({ + source: 'interactionCutocompleteHandler.ts', + module: 'handler', + name: 'interactionAutocompleteHandler', + executionId: executionId + }); + const autocompleteModule = await import(`../interactions/autocomplete/${interaction.commandName}.js`); const { default: autocomplete } = autocompleteModule; diff --git a/src/handlers/interactionCommandHandler.ts b/src/handlers/interactionCommandHandler.ts index 4bef498..6155704 100644 --- a/src/handlers/interactionCommandHandler.ts +++ b/src/handlers/interactionCommandHandler.ts @@ -3,17 +3,18 @@ import { Command, ExtendedClient } from '../types/clientTypes'; import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator'; import loggerModule from '../services/logger'; -const logger = loggerModule.child({ - source: 'interactionCommandHandler.ts', - module: 'handler', - name: 'interactionCommandHandler' -}); - export const handleCommand = async ( interaction: ChatInputCommandInteraction, client: ExtendedClient, executionId: string ) => { + const logger = loggerModule.child({ + source: 'interactionCommandHandler.ts', + module: 'handler', + name: 'interactionCommandHandler', + executionId: executionId + }); + await interaction.deferReply(); logger.debug('Interaction deferred.'); diff --git a/src/handlers/interactionComponentHandler.ts b/src/handlers/interactionComponentHandler.ts index bf4109a..5b30ab6 100644 --- a/src/handlers/interactionComponentHandler.ts +++ b/src/handlers/interactionComponentHandler.ts @@ -2,13 +2,14 @@ import { MessageComponentInteraction } from 'discord.js'; import loggerModule from '../services/logger'; import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator'; -const logger = loggerModule.child({ - source: 'interactionComponentHandler.js', - module: 'handler', - name: 'interactionComponentHandler' -}); - export const handleComponent = async (interaction: MessageComponentInteraction, executionId: string) => { + const logger = loggerModule.child({ + source: 'interactionComponentHandler.js', + module: 'handler', + name: 'interactionComponentHandler', + executionId: executionId + }); + await interaction.deferReply(); logger.debug('Interaction deferred.'); diff --git a/src/handlers/interactionErrorHandler.ts b/src/handlers/interactionErrorHandler.ts index 9b769d2..02dbc84 100644 --- a/src/handlers/interactionErrorHandler.ts +++ b/src/handlers/interactionErrorHandler.ts @@ -6,19 +6,19 @@ import { CustomError } from '../types/interactionTypes'; const embedOptions: EmbedOptions = config.get('embedOptions'); const botOptions: BotOptions = config.get('botOptions'); - -const logger = loggerModule.child({ - source: 'interactionErrorHandler.ts', - module: 'handler', - name: 'interactionErrorHandler' -}); - export const handleError = async ( interaction: Interaction, error: CustomError, interactionIdentifier: string, executionId: string ) => { + const logger = loggerModule.child({ + source: 'interactionErrorHandler.ts', + module: 'handler', + name: 'interactionErrorHandler', + executionId: executionId + }); + const errorReply = { embeds: [ new EmbedBuilder() @@ -30,7 +30,7 @@ export const handleError = async ( ] }; - logger.error(error, `Error handling interaction '${interactionIdentifier}'`); + logger.error({ error, interaction }, `Error handling interaction '${interactionIdentifier}'`); if (interaction instanceof ChatInputCommandInteraction && interaction.deferred) { switch (interaction.replied) {