Discord.py discordpythonbot创建:清除消息命令,显示删除了多少消息

Discord.py discordpythonbot创建:清除消息命令,显示删除了多少消息,discord.py,Discord.py,我需要帮助,使机器人回应我的确切数量有多少消息被清除 我打字的时候!清除15则删除12条消息我希望它以“清除12条消息”回复我 我试过这样的方法: @commands.command() async def clear(self, ctx, amount=10): await ctx.channel.purge(limit=amount) await ctx.send(amount, 'messages cleared') 我知道这不会显示它清除了多少条消息,但会

我需要帮助,使机器人回应我的确切数量有多少消息被清除

我打字的时候!清除15则删除12条消息我希望它以“清除12条消息”回复我

我试过这样的方法:

  @commands.command()
  async def clear(self, ctx, amount=10):
    await ctx.channel.purge(limit=amount)
    await ctx.send(amount, 'messages cleared')
  
我知道这不会显示它清除了多少条消息,但会显示它试图清除了多少条消息(当然,如果它确实起作用,就会发生这种情况,但它没有按预期工作)

我对此搜索了很多,但在任何地方都找不到类似的帖子,希望有人能帮助我。

返回已删除邮件的列表,您只需使用
len()

deleted_messages=wait ctx.channel.purge(限制=数量)
等待ctx.send(f“{len(deleted_messages)-1}messages cleared”)#减去1,因为它是命令的消息
此外,还应键入提示
金额
参数,以便自动将其转换为整数

异步def清除(自身、ctx、金额:int=10):