Compare commits
2 Commits
04fad613b6
...
974d01a08f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
974d01a08f | ||
|
|
4964bf50e1 |
21
index.js
21
index.js
@ -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) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user