From 9210c22dde3e80a37d1f0a0d1d0402f67242cb8e Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:27:10 +0400 Subject: [PATCH 1/2] debug: add more logs to check hivemind slash command --- src/commands/info/question.ts | 3 ++- src/services/interaction.service.ts | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/commands/info/question.ts b/src/commands/info/question.ts index 5025655c..5b27ca1c 100644 --- a/src/commands/info/question.ts +++ b/src/commands/info/question.ts @@ -53,7 +53,8 @@ export default { }); logger.info({ interaction_id: interaction.id, user: interaction.user }, 'question command ended'); } catch (error) { - logger.error(error, 'is failed'); + logger.error(error, 'question command is failed'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'question command is failed'); await interactionService.createInteractionResponse(interaction, { type: 4, data: { diff --git a/src/services/interaction.service.ts b/src/services/interaction.service.ts index 4eda8a0d..3b125341 100644 --- a/src/services/interaction.service.ts +++ b/src/services/interaction.service.ts @@ -40,10 +40,12 @@ async function createInteractionResponse( }, ); if (!response.ok) { - throw new Error(); + const errorResponse = await response.text(); + throw new Error(errorResponse); } } catch (error) { logger.error(error, 'Failed to send interaction response'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); } } @@ -74,10 +76,12 @@ async function getOriginalInteractionResponse(interaction: ChatInputCommandInter if (response.ok) { return await response.json(); } else { - throw new Error(await response.json()); + const errorResponse = await response.text(); + throw new Error(errorResponse); } } catch (error) { logger.error(error, 'Failed to get original interaction response'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); } } @@ -112,10 +116,12 @@ async function editOriginalInteractionResponse( if (response.ok) { return await response.json(); } else { - throw new Error(await response.json()); + const errorResponse = await response.text(); + throw new Error(errorResponse); } } catch (error) { logger.error(error, 'Failed to edit original interaction response'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); } } @@ -144,10 +150,12 @@ async function deleteOriginalInteractionResponse(interaction: ChatInputCommandIn }, ); if (!response.ok) { - throw new Error(await response.json()); + const errorResponse = await response.text(); + throw new Error(errorResponse); } } catch (error) { logger.error(error, 'Failed to delete original interaction response'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); } } @@ -176,10 +184,12 @@ async function createFollowUpMessage(interaction: ChatInputCommandInteraction_br if (response.ok) { return await response.json(); } else { - throw new Error(await response.json()); + const errorResponse = await response.text(); + throw new Error(errorResponse); } } catch (error) { logger.error(error, 'Failed to create follow up message'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); } } From f45b61de988b6e30f3082169b0d41888751627ea Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:58:26 +0400 Subject: [PATCH 2/2] debug: add more logs to check hivemind slash command --- src/services/interaction.service.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/services/interaction.service.ts b/src/services/interaction.service.ts index 3b125341..fb61f43b 100644 --- a/src/services/interaction.service.ts +++ b/src/services/interaction.service.ts @@ -81,7 +81,10 @@ async function getOriginalInteractionResponse(interaction: ChatInputCommandInter } } catch (error) { logger.error(error, 'Failed to get original interaction response'); - logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); + logger.error( + { interaction_id: interaction.id, user: interaction.user }, + 'Failed to get original interaction response', + ); } } @@ -121,7 +124,10 @@ async function editOriginalInteractionResponse( } } catch (error) { logger.error(error, 'Failed to edit original interaction response'); - logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); + logger.error( + { interaction_id: interaction.id, user: interaction.user }, + 'Failed to edit original interaction response', + ); } } @@ -155,7 +161,10 @@ async function deleteOriginalInteractionResponse(interaction: ChatInputCommandIn } } catch (error) { logger.error(error, 'Failed to delete original interaction response'); - logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); + logger.error( + { interaction_id: interaction.id, user: interaction.user }, + 'Failed to delete original interaction response', + ); } } @@ -189,7 +198,7 @@ async function createFollowUpMessage(interaction: ChatInputCommandInteraction_br } } catch (error) { logger.error(error, 'Failed to create follow up message'); - logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to send interaction response'); + logger.error({ interaction_id: interaction.id, user: interaction.user }, 'Failed to create follow up message'); } }