Reputation: 1
I'm trying to make a bot that will delete all messages from another bot. A bot malfunctioned and spammed a whole bunch of messages, and so I want to delete the messages, which would take absurdly long.
Upvotes: 0
Views: 237
Reputation: 218
You can fetch all messages from the channel. Then filter it by userID and delete
In your post you said that your bot spammed the messages so this code is for removing your bot's messages
message.channel.messages.fetch().then(messages => {
const botMessages = messages.filter(msg => msg.author.bot);
message.channel.bulkDelete(botMessages);
})
Upvotes: 1