Reputation: 41
I forgot to add a bot-check in my code before testing the bot, and my discord dm channel looks horrible. I'm trying to have the bot go in and delete the messages, but I can't find a command that will work for that.
message.delete()
only works for the message that was sent last, and channel.purge
seems to work only for messages sent in a server, not dms.
I've already looked through the discord API references, but either I missed something, or I just can't find the command that I need. I've left links for both dm and regular channels, but I really want to clear the mess that I inadvertnetly made:
discord dm channel discord regular channel
Upvotes: 2
Views: 1215
Reputation: 41
I solved this by manually getting the id of every message, putting it into an array, and using await message.delete()
in a loop to delete all of the messages
Upvotes: 0
Reputation: 205
You're probably only deleting the last message because the message
variable is the one that was just passed to the bot. Instead, you need to store all the messages in an array messages
from which you can run something like this:
for message in messages: await message.delete()
Upvotes: 1