【问题标题】:Discord Python Bot- fixing clear commandDiscord Python Bot- 修复清除命令
【发布时间】:2021-07-25 21:49:05
【问题描述】:

我的 Bot 有一个命令可以清除一些单词或所有内容...

这是我的代码:

@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount: int = None):
    if amount == 0:
        await ctx.channel.purge(limit=10000000000000000000000)
        await ctx.send("Cleared the entire chat!")
        print("Cleared the chat!")
    else:
        await ctx.channel.purge(limit=amount)
        await ctx.send("Done!")
        print(f"Cleared {amount} messages!")

但如果我只是写 >clear 它会清除所有内容...我怎么能说它什么都不会清除或在 >clear 处说“输入金额”? 感谢您的帮助

【问题讨论】:

    标签: python list discord bots embed


    【解决方案1】:

    好的,修复它...

    @bot.command(aliases=['c'])
    @commands.has_permissions(manage_messages=True)
    async def clear(ctx, amount: int = None):
        if amount == 0:
            await ctx.channel.purge(limit=10000000000000000000000)
            await ctx.send("Cleared the entire chat!")
            print("Cleared the chat!")
        else:
            if amount >= 1:
                await ctx.channel.purge(limit=amount)
                await ctx.send("Done!")
                print(f"Cleared {amount} messages!")
    
            else:
                return
    

    【讨论】:

      猜你喜欢
      • 2018-10-21
      • 2021-03-01
      • 2018-09-17
      • 2021-04-11
      • 2020-08-11
      • 2021-02-17
      • 2019-03-07
      • 2018-03-04
      • 1970-01-01
      相关资源
      最近更新 更多