问题描述
所以我想清除特定成员的消息。这是我的代码。
@commands.command()
async def purge_member(self,ctx,member: discord.Member):
await ctx.channel.purge(limit=100,check=lambda message: message.author == member)
我尝试了许多其他方法而不是清除来删除,但它们都拒绝工作,没有错误
解决方法
如果您有 on_message
事件,请在其末尾添加 process_commands
# 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)
如果你没有取消注释代码,否则它不会工作
# 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,check=lambda message: message.author == member)