sleepy-discord icon indicating copy to clipboard operation
sleepy-discord copied to clipboard

Delete all messages in a Discord channel

Open Paket236 opened this issue 5 years ago • 5 comments

Is it possible to delete all messages from a Discord channel ?

Paket236 avatar Mar 07 '19 22:03 Paket236

yes with bulk delete, however, it's going to take a while to get all the message ids

yourWaifu avatar Mar 08 '19 03:03 yourWaifu

Ok, I can get the lastMessageID, but how can I get IDs of previous messages?

Paket236 avatar Mar 08 '19 11:03 Paket236

use getMessages, try not to spam it tho.

yourWaifu avatar Mar 08 '19 17:03 yourWaifu

Also can't you just delete a channel and recreate?

yourWaifu avatar Mar 08 '19 17:03 yourWaifu

Thanks, now I figured it out! However, on the run() function, an exception of type SleepyDiscord::ErrorCode with code 5005 is sometimes generated (if spamming), so I had to add exception handling and wrap it in a loop, as shown below. I hope so normal (I mean cycle).

	thread t1( [&client]() {
		while(true) {
			try {
				client.run();
			}  catch (SleepyDiscord::ErrorCode i) {}
		}
	});
	t1.detach();

Paket236 avatar Mar 09 '19 21:03 Paket236