Python 如何使用Discord bot删除频道中的所有邮件

Python 如何使用Discord bot删除频道中的所有邮件,python,bots,discord,discord.py,Python,Bots,Discord,Discord.py,我想做的是,当发送指定的命令“m!clear”时,bot将删除该通道中的所有消息(或特定数量)。我已经有了if message.content.startswith('m!clear):但是我不知道下一部分该怎么做。删除所有的消息不是很好。我可以与您共享删除特定数量邮件的代码 @bot.command() @commands.has_permissions(manage_messages=True) #only those with the permission to manage messa

我想做的是,当发送指定的命令“m!clear”时,bot将删除该通道中的所有消息(或特定数量)。我已经有了
if message.content.startswith('m!clear):
但是我不知道下一部分该怎么做。

删除所有的消息不是很好。我可以与您共享删除特定数量邮件的代码

@bot.command()
@commands.has_permissions(manage_messages=True) 
#only those with the permission to manage messages can use this command

async def clear(ctx, amount: int):
    await ctx.channel.purge(limit=amount + 1)
    await ctx.send(f"{amount} message(s) got deleted")

要使用此选项,请使用[command][value]
i、 e:清除10,但我不知道下一部分该怎么做。你能说得更具体一点吗?我想,只要我!明确地说,我删除了所有或一组消息。我不确定执行此操作的代码。我不确定执行此操作的代码。好的,那么你通常是如何解决问题的呢?你试过把任务写在纸上吗?