[英]discord.py purge command not working and no error
所以我想清除特定成员的消息。 这是我的代码。
@commands.command()
async def purge_member(self, ctx, member: discord.Member):
await ctx.channel.purge(limit=100, check=lambda message: message.author == member)
问题是成员的消息没有被清除。 它也没有显示任何错误。
我尝试了许多其他方法而不是 purge 来删除,但它们都拒绝工作,没有错误
如果您有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, member: discord.Member):
await ctx.channel.purge(limit=100, check=lambda message: message.author == member)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.