Added new tryCatch wrapper

This commit is contained in:
2025-03-20 23:41:18 +01:00
parent e555417e13
commit 95f9bb723f
16 changed files with 255 additions and 269 deletions

View File

@@ -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")
})
}