0
votes

I am creating a bot written in python for Discord. I want it to be able to delete specific user's messages, instead of just every message in the text channel. I saw another post on here that helped a bit, but I am having trouble figuring out how to do the 'specific user' part. Here's what I have:

@client.command(pass_context = True)
async def purge(ctx, number):
    number = int(number) #Converting the amount of messages to delete to an integer
    counter = 0
    async for x in client.logs_from(ctx.message.channel, limit = number):
        if counter < number:
            await client.delete_message(x)
            counter += 1
1

1 Answers

0
votes

According to the docs the message object contains information about its author. All you need to do is to check if the returned author is the one you want to delete the messages from. You will have to check that for every message in the channel.