B3RS3RK3R_01
B3RS3RK3R_01

Reputation: 3

How do I command the discord.py bot to remove messages from a specific member?

I wanted to make a command so that I mark a member and the bot deletes all his messages.

it would be something like:

from discord.ext import commands
from discord import *

bot = commands.bot(command_prefix="Mia ", case_insensitive = "True", intents=Intents.all())

@bot.command(name="clean")
async def clear(ctx, m:discord.Member):
  await m.message.delete_all()

bot.run("Token")

Note: this was just a hypothetical code, it doesn't work

Upvotes: 0

Views: 125

Answers (1)

cheetah
cheetah

Reputation: 331

You could iterate through all of the guilds channels, and for each channel, iterate through its history (here). You can then check each message in the history to see if the author is the member you're dealing with, and if so, delete the message.

Upvotes: 1

Related Questions