Answer the question
In order to leave comments, you need to log in
How to delete messages of a specified Discord user Python?
I'm writing a bot and I ran into a problem: I need a clear command that will delete messages. It should delete only those messages that the user himself wrote, without touching others. And this is how it really works:
@bot.command(pass_contex=True)
async def clear(ctx, arg=None):
arg = arg + 1
await ctx. channel.purge(limit=arg, check=lambda message: message.author == ctx.author)
await ctx.send(f'Удалено ` {arg - 1} ` сообщений', delete_after=5)
Answer the question
In order to leave comments, you need to log in
Or accept that the team is looking for your messages among the N last ones, and not looking for your N last ones.
Or download the chat history and find how many messages have been since the Nth time of your message.
I must say right away that the latter can be dreary in implementation and slowed down in practice. What if 100,500 others have written in the chat since your old overwritten message?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question