Discord Bot can't delete messages from dms
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
Solution 1:
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()