Added new tryCatch wrapper
This commit is contained in:
@@ -5,6 +5,7 @@ import { embedColor } from "~/config/options"
|
||||
import { IModal } from "~/typings"
|
||||
import { ExtendedClient as Client } from "~/utils/Client"
|
||||
import logToChannel from "~/utils/Functions/logtochannel"
|
||||
import tryCatch from "../Functions/trycatch"
|
||||
import { log } from "../Logger"
|
||||
type FileType = "js" | "ts"
|
||||
|
||||
@@ -32,39 +33,38 @@ export default async function loadModalEvents(client: Client, ft: FileType) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await modal.execute({ interaction, client })
|
||||
} catch (error) {
|
||||
if (process.env.NODE_ENV !== "dev") {
|
||||
await logToChannel("error", {
|
||||
embeds: [{
|
||||
title: "Button error occured",
|
||||
description: "```" + error + "```",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
icon_url: interaction.guild!.iconURL() || undefined,
|
||||
text: interaction.user.username + " | " + interaction.customId
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
const [error] = await tryCatch(modal.execute({ interaction, client }))
|
||||
if (!error) return
|
||||
|
||||
log(error, "error")
|
||||
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
|
||||
}]
|
||||
})
|
||||
}
|
||||
if (process.env.NODE_ENV !== "dev") {
|
||||
await logToChannel("error", {
|
||||
embeds: [{
|
||||
title: "Button error occured",
|
||||
description: "```" + error + "```",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
icon_url: interaction.guild!.iconURL() || undefined,
|
||||
text: interaction.user.username + " | " + interaction.customId
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
log(error, "error")
|
||||
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
|
||||
}]
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user