mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix: Fix logger for handlers not including executionId
This commit is contained in:
1 parent
9ed14f0b8f
commit
0db7bb0cf3
4 files changed
+29
-26
No files matched your search
@@ -1,13 +1,14 @@
|
|||||||
import { AutocompleteInteraction } from 'discord.js';
|
import { AutocompleteInteraction } from 'discord.js';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
|
|
||||||
const logger = loggerModule.child({
|
|
||||||
source: 'interactionCutocompleteHandler.ts',
|
|
||||||
module: 'handler',
|
|
||||||
name: 'interactionAutocompleteHandler'
|
|
||||||
});
|
|
||||||
|
|
||||||
export const handleAutocomplete = async (interaction: AutocompleteInteraction, executionId: string) => {
|
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 autocompleteModule = await import(`../interactions/autocomplete/${interaction.commandName}.js`);
|
||||||
const { default: autocomplete } = autocompleteModule;
|
const { default: autocomplete } = autocompleteModule;
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,18 @@ import { Command, ExtendedClient } from '../types/clientTypes';
|
|||||||
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
|
|
||||||
const logger = loggerModule.child({
|
|
||||||
source: 'interactionCommandHandler.ts',
|
|
||||||
module: 'handler',
|
|
||||||
name: 'interactionCommandHandler'
|
|
||||||
});
|
|
||||||
|
|
||||||
export const handleCommand = async (
|
export const handleCommand = async (
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
client: ExtendedClient,
|
client: ExtendedClient,
|
||||||
executionId: string
|
executionId: string
|
||||||
) => {
|
) => {
|
||||||
|
const logger = loggerModule.child({
|
||||||
|
source: 'interactionCommandHandler.ts',
|
||||||
|
module: 'handler',
|
||||||
|
name: 'interactionCommandHandler',
|
||||||
|
executionId: executionId
|
||||||
|
});
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
logger.debug('Interaction deferred.');
|
logger.debug('Interaction deferred.');
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import { MessageComponentInteraction } from 'discord.js';
|
|||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
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) => {
|
export const handleComponent = async (interaction: MessageComponentInteraction, executionId: string) => {
|
||||||
|
const logger = loggerModule.child({
|
||||||
|
source: 'interactionComponentHandler.js',
|
||||||
|
module: 'handler',
|
||||||
|
name: 'interactionComponentHandler',
|
||||||
|
executionId: executionId
|
||||||
|
});
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
logger.debug('Interaction deferred.');
|
logger.debug('Interaction deferred.');
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ import { CustomError } from '../types/interactionTypes';
|
|||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const botOptions: BotOptions = config.get('botOptions');
|
const botOptions: BotOptions = config.get('botOptions');
|
||||||
|
|
||||||
const logger = loggerModule.child({
|
|
||||||
source: 'interactionErrorHandler.ts',
|
|
||||||
module: 'handler',
|
|
||||||
name: 'interactionErrorHandler'
|
|
||||||
});
|
|
||||||
|
|
||||||
export const handleError = async (
|
export const handleError = async (
|
||||||
interaction: Interaction,
|
interaction: Interaction,
|
||||||
error: CustomError,
|
error: CustomError,
|
||||||
interactionIdentifier: string,
|
interactionIdentifier: string,
|
||||||
executionId: string
|
executionId: string
|
||||||
) => {
|
) => {
|
||||||
|
const logger = loggerModule.child({
|
||||||
|
source: 'interactionErrorHandler.ts',
|
||||||
|
module: 'handler',
|
||||||
|
name: 'interactionErrorHandler',
|
||||||
|
executionId: executionId
|
||||||
|
});
|
||||||
|
|
||||||
const errorReply = {
|
const errorReply = {
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
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) {
|
if (interaction instanceof ChatInputCommandInteraction && interaction.deferred) {
|
||||||
switch (interaction.replied) {
|
switch (interaction.replied) {
|
||||||
|
|||||||
Reference in new issue
Block a user