feat: delete old messages on start
This commit is contained in:
parent
4964bf50e1
commit
974d01a08f
10
index.js
10
index.js
@ -20,6 +20,16 @@ const client = new Client({
|
|||||||
|
|
||||||
client.on("ready", () => {
|
client.on("ready", () => {
|
||||||
console.log(`Logged in as ${client.user.tag}!`);
|
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
|
// send message on error
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user