From 344885bcacf3d95741a0ae6e23c79f11dce02d01 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Fri, 7 Jul 2023 22:11:46 +0200 Subject: [PATCH] Fix embed reply on unhandled error. Better error logging. --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 96925bf..c46e9ee 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const fs = require('node:fs'); const Discord = require('discord.js'); +const { EmbedBuilder } = require('discord.js'); const { Player } = require('discord-player'); const { token, embedColors } = require('./config.json'); @@ -110,7 +111,8 @@ client.on('interactionCreate', async (interaction) => { }' was executed successfully.` ); } catch (error) { - console.error(error); + // log error to console with full object depth + console.dir(error, { depth: null }); console.log( `${new Date().toISOString().substring(11, 19)}: ${ interaction.guild.name @@ -118,12 +120,13 @@ client.on('interactionCreate', async (interaction) => { interaction.commandName }' failed unexpectedly.` ); + console.log(`Interaction input:\n${interaction}`); await interaction.editReply({ embeds: [ new EmbedBuilder() .setDescription( - `**Error**\nThere was an error while executing this command!\n\nIf this issue persists, please submit an issue in the support server: https://discord.gg/t6Bm8wPpXB` + `**Unexpected Error**\nThere was an error while executing this command! Please try again.\n\n_If this issue persists, please submit a bug report in the bot [support server](https://discord.gg/t6Bm8wPpXB)._` ) .setColor(embedColors.colorError) ]