So I want to purge the message of a particular member. This is my code.
@commands.command()
async def purge_member(self, ctx, member: discord.Member):
await ctx.channel.purge(limit=100, check=lambda message: message.author == member)
The problem is the messages of the member are not getting purged. It does not show any error either.
I have tried many other methods instead of purge to delete but all of them refuse to work, with no errors
If you have an on_message
event, add process_commands
at the end of it
# In Cog
@commands.Cog.listener()
async def on_message(m):
...
await self.bot.process_commands(m)
# In Main File
@bot.event
async def on_message(m):
...
await bot.process_commands(m)
If you have not un-commented the code do it else it won't work
# In Cog
@commands.command()
async def purge_member(self, ctx, member: discord.Member):
await ctx.channel.purge(limit=100, check=lambda message: message.author == member)
# In Main File
@bot.command()
async def purge_member(ctx, member: discord.Member):
await ctx.channel.purge(limit=100, check=lambda message: message.author == member)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.