不同的角色有不同的冷却时间discord.py

Different roles have different cooldowns discord.py

目前我有这个:

@client.command()
async def test(ctx):
    if ctx.message.author.has_role(803952153496256512):
        @commands.cooldown(3, 60, commands.BucketType.user)
    elif ctx.message.author.has_role(803952219694432326 ):
        @commands.cooldown(5, 60, commands.BucketType.user)
    elif ctx.message.author.has_role(803952282198212668 ):
        @commands.cooldown(7, 60, commands.BucketType.user)
    else:
        return

我想要它,所以如果用户具有特定角色,命令的冷却时间会有所不同

我从来都不是配置冷却时间的最佳人选,但我可以帮助你的是你的角色检测。为了判断一个成员是否有角色,我们需要一些东西;成员对象和角色 ID。看起来你的命令上下文中包含所有这些,所以我们应该写一些代码。我只是将您的代码改造成更像这样的东西。

@client.command()
async def test(ctx):
    if any([discord.utils.get(ctx.author.roles, id = 803952153496256512)]):
        pass
    elif any([discord.utils.get(ctx.author.roles, id = 803952219694432326)]):
        pass
    elif any([discord.utils.get(ctx.author.roles, id = 803952282198212668)]):
        pass