Added new tryCatch wrapper
This commit is contained in:
@@ -5,6 +5,7 @@ import { embedColor } from "~/config/options"
|
||||
import { IAutocomplete } 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"
|
||||
|
||||
@@ -28,23 +29,22 @@ export default async function loadAutocompleteEvents(client: Client, ft: FileTyp
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await autocomplete.execute({ interaction, client })
|
||||
} catch (error) {
|
||||
if (process.env.NODE_ENV !== "dev") {
|
||||
await logToChannel("error", {
|
||||
embeds: [{
|
||||
title: "Autocomplete error occured",
|
||||
description: "```" + error + "```",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
icon_url: interaction.guild!.iconURL() || undefined,
|
||||
text: interaction.user.username + " | " + interaction.commandName
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
log(error, "error")
|
||||
const [error] = await tryCatch(autocomplete.execute({ interaction, client }))
|
||||
if (!error) return
|
||||
|
||||
if (process.env.NODE_ENV !== "dev") {
|
||||
await logToChannel("error", {
|
||||
embeds: [{
|
||||
title: "Autocomplete error occured",
|
||||
description: "```" + error + "```",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
icon_url: interaction.guild!.iconURL() || undefined,
|
||||
text: interaction.user.username + " | " + interaction.commandName
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
log(error, "error")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user