I have a bot that I was testing by making it send DMs to my account but now I want to delete the messages that are already sent. I have searched all over and I did not find any thing. In short I need to know how to make my bot delete it’s own messages from the command user's DM.
I try the method @Mars Buttfield-Addison told me and I am geting a error ERROR:
Ignoring exception in command clear_dm:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 50, in clear_dm
async for message in client.user.dm_channel.history(limit=messages_to_remove):
AttributeError: 'ClientUser' object has no attribute 'dm_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'dm_channel'