chore: catch errors and log them?

This commit is contained in:
ethanf 2023-12-15 22:49:34 -06:00
parent 04fad613b6
commit 4964bf50e1

View File

@ -22,6 +22,17 @@ client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});
// send message on error
client.on("error", (error) => {
console.error(error);
let channel = client.channels.cache.get(COMMAND_CHANNEL_ID);
if (!channel) return console.error("Can't find command channel");
client.channels.cache
.get(COMMAND_CHANNEL_ID)
.send(`error: ${error.message}`)
.catch(console.error);
});
client.on("interactionCreate", async (interaction) => {
const command = interaction.commandName;
if (!interaction.isChatInputCommand()) return;