diff --git a/src/utils/eventHandlers/button.ts b/src/utils/eventHandlers/button.ts index 427a771..d8e7516 100644 --- a/src/utils/eventHandlers/button.ts +++ b/src/utils/eventHandlers/button.ts @@ -41,12 +41,11 @@ export default function loadButtonEvents(client: Client, ft: FileType) { await button.execute(interaction) } catch (error) { if (process.env.NODE_ENV !== "dev") { - await logToChannel("error", { embeds: [ { title: "Button error occured", - description: String(error), + description: "```" + error + "```", color: embedColor, footer: { icon_url: interaction.guild!.iconURL() || undefined, @@ -59,11 +58,24 @@ export default function loadButtonEvents(client: Client, ft: FileType) { ], }) } + console.error(error) - await interaction.reply({ - content: "There was an error while executing this event!", - ephemeral: true, - }) + if (!interaction.deferred) { + await interaction.reply({ + embeds: [{ + description: "There was an error while executing this button!", + color: embedColor, + }], + ephemeral: true, + }) + } else { + await interaction.editReply({ + embeds: [{ + description: "There was an error while executing this button! 2", + color: embedColor, + }] + }) + } } }) } diff --git a/src/utils/eventHandlers/command.ts b/src/utils/eventHandlers/command.ts index ffe3bca..7fa329b 100644 --- a/src/utils/eventHandlers/command.ts +++ b/src/utils/eventHandlers/command.ts @@ -46,7 +46,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) { embeds: [ { title: "Command error occured", - description: String(error), + description: "```" + error + "```", color: embedColor, footer: { icon_url: interaction.guild!.iconURL() || undefined, @@ -61,10 +61,22 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) { } console.error(error) - await interaction.reply({ - content: "There was an error while executing this command!", - ephemeral: true, - }) + if (!interaction.deferred) { + await interaction.reply({ + embeds: [{ + description: "There was an error while executing this command!", + color: embedColor, + }], + ephemeral: true, + }) + } else { + await interaction.editReply({ + embeds: [{ + description: "There was an error while executing this command!", + color: embedColor, + }] + }) + } } }) } diff --git a/src/utils/eventHandlers/contextmenu.ts b/src/utils/eventHandlers/contextmenu.ts index 29db098..97c1709 100644 --- a/src/utils/eventHandlers/contextmenu.ts +++ b/src/utils/eventHandlers/contextmenu.ts @@ -53,7 +53,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) { embeds: [ { title: "Contextmenu error occured", - description: String(error), + description: "```" + error + "```", color: embedColor, footer: { icon_url: interaction.guild!.iconURL() || undefined, @@ -66,11 +66,24 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) { ], }) } + console.error(error) - await interaction.reply({ - content: "There was an error while executing this command!", - ephemeral: true, - }) + if (!interaction.deferred) { + await interaction.reply({ + embeds: [{ + description: "There was an error while executing this contextmenu command!", + color: embedColor, + }], + ephemeral: true, + }) + } else { + await interaction.editReply({ + embeds: [{ + description: "There was an error while executing this contextmenu command!", + color: embedColor, + }] + }) + } } }) } diff --git a/src/utils/eventHandlers/modal.ts b/src/utils/eventHandlers/modal.ts index dbc6dd7..94a0d05 100644 --- a/src/utils/eventHandlers/modal.ts +++ b/src/utils/eventHandlers/modal.ts @@ -47,7 +47,7 @@ export default function loadModalEvents(client: Client, ft: FileType) { embeds: [ { title: "Button error occured", - description: String(error), + description: "```" + error + "```", color: embedColor, footer: { icon_url: interaction.guild!.iconURL() || undefined, @@ -60,11 +60,23 @@ export default function loadModalEvents(client: Client, ft: FileType) { ], }) } + console.error(error) - await interaction.reply({ - content: "There was an error while executing this modal!", - ephemeral: true, - }) + if (!interaction.deferred) { + await interaction.reply({ + embeds: [{ + description: "There was an error while executing this modal!", + color: embedColor + }] + }) + } else { + await interaction.editReply({ + embeds: [{ + description: "There was an error while executing this modal!", + color: embedColor + }] + }) + } } }) }