How would I delete some messages from a channel with discord.js ? I get the number as an argument for the delete
command, but I just can't figure out how to actually delete it. I've looked at other questions, the code I saw started with channel.fetchMessages
which for some reason is not a function anymore. This is the code I currently have: channel.fetchMessages({ limit: num }).then(messages => channel.bulkDelete(messages));
Asked
Active
Viewed 116 times
0

ProgRAMmer
- 31
- 6
2 Answers
0
Ah okay, I found it. It was channel.messages.fetch({ limit: num }).then(messages => channel.bulkDelete(messages));

ProgRAMmer
- 31
- 6
0
msg.channel.bulkDelete(num)
.then(messages => {msg.channel.send(`** \`${messages.size}/${num}\` messages deleted successfully** `)}).then(msg => msg.delete({timeout: 10000}))
it is also shows the count of deleted messages
if you don't want it this would be enough:
msg.channel.bulkDelete(num)

ExDet
- 158
- 11