Delete Messages in a Channel (Not Purge)

How would I delete all the messages in a channel without knowing how many messages are in the channel?
9 Replies
Noby
Noby2y ago
Here's what I have now:
await channel.messages.cache.forEach(async (message) => {
await message.delete().catch(err => console.log(err)).finally(console.log("deleted all the messages"));
});
await channel.messages.cache.forEach(async (message) => {
await message.delete().catch(err => console.log(err)).finally(console.log("deleted all the messages"));
});
monbrey
monbrey2y ago
Can't, just delete the channel and remake it
Noby
Noby2y ago
But it isn't working
monbrey
monbrey2y ago
That's insane API spam
Noby
Noby2y ago
tragic So there's no other way except purge?
monbrey
monbrey2y ago
bulkDelete will go back 14 days at most
Noby
Noby2y ago
Yep ik
monbrey
monbrey2y ago
Clone channel, delete original is best way
Noby
Noby2y ago
rip then ok