Compare commits

...

2 Commits

Author SHA1 Message Date
ethanf
974d01a08f feat: delete old messages on start 2023-12-15 22:56:29 -06:00
ethanf
4964bf50e1 chore: catch errors and log them? 2023-12-15 22:49:34 -06:00

View File

@ -20,6 +20,27 @@ const client = new Client({
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log(`Deleting old messages from this bot in command channel: ${COMMAND_CHANNEL_ID}...`);
let channel = client.channels.cache.get(COMMAND_CHANNEL_ID);
if (!channel) return console.error("(ready) Can't find command channel");
channel.messages.fetch({ limit: 100 }).then(messages => {
messages.forEach(message => {
if (message.author.id === client.user.id) {
message.delete();
}
});
}).catch(console.error);
});
// 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) => {