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

@@ -51,22 +51,33 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
try {
await autocomplete.execute(interaction)
} catch (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: "Autocomplete error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.user.username + " | " + interaction.commandName
}
}],
})
await channel.send({
embeds: [
{
title: "Autocomplete error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text:
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
})
}
console.error(error)
}
})

View File

@@ -39,22 +39,33 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
try {
await button.execute(interaction)
} catch (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 event!",

View File

@@ -40,24 +40,35 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
try {
await command.execute(interaction, client)
} catch (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: "Command error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text:
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
})
}
await channel.send({
embeds: [{
title: "Command error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.user.username + " | " + interaction.commandName
}
}],
})
console.error(error)
// console.error(error)
await interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true,

View File

@@ -47,22 +47,33 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
try {
await command.execute(interaction)
} catch (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: "Contextmenu error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.user.username + " | " + interaction.commandName
}
}],
})
await channel.send({
embeds: [
{
title: "Contextmenu error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
text:
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
})
}
console.error(error)
await interaction.reply({
content: "There was an error while executing this command!",

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,