Updated event handlers to send error message only if prod

This commit is contained in:
2024-01-03 16:05:57 +01:00
parent 7e00569fbe
commit 386ed4205f
5 changed files with 132 additions and 77 deletions

View File

@@ -41,23 +41,34 @@ export default function loadModalEvents(client: Client, ft: FileType) {
try {
await modal.execute(interaction)
} catch (error) {
console.error(error)
const channel = client.channels.cache.get(errorLogChannel) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get(
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({
embeds: [{
title: "Button error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.user.username + " | " + interaction.customId
}
}],
})
await channel.send({
embeds: [
{
title: "Button error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text:
interaction.user.username +
" | " +
interaction.customId,
},
},
],
})
}
console.error(error)
await interaction.reply({
content: "There was an error while executing this modal!",
ephemeral: true,