尝试为同一命令(discord.py)添加不同的冷却时间

时间:2020-08-21 13:45:30

标签: python discord.py

@client.command(aliases = ['Missao', 'missão', 'missao', 'm'])
async def mission(ctx, rank = None):
    if f'{ctx.channel.id}' == '745647726804336702':
        if rank == None:
            await ctx.send('Voce nao especificou o rank da missao!')
        elif rank == 'E' or rank == 'e':
            responses = ['Salve o gato na arvore!', 
            'Limpe a rua, esta cheia de lixo.', 
            'Um bando de delinquentes pixou o muro da praca, por favor limpe-os.', 
            'Outono chegou, as folhas estao caindo, poderia recolher algumas por favor.']
            missionEmbed = discord.Embed(
                title = "Missao Rank E",
                description = f'{random.choice(responses)}',
                colour = discord.Colour.green()
            )
            missionEmbed.add_field(name = 'Recompensa', value = '1.000 - 5.000 :moneybag:\n 1 - 10 **SP**', inline = True)
            missionEmbed.add_field(name = 'Linhas', value = '30', inline = True)
            missionEmbed.set_author(name = f'Missao de {ctx.message.author.nick}', icon_url = ctx.message.author.avatar_url)
            await ctx.channel.send(embed = missionEmbed)
        elif rank == 'D' or rank == 'd':
            responses = ['Um bandido esta assaltando o restaurante!', 
            '2 garotos estao brigando do lado da escola, pare-os.']
            missionEmbed = discord.Embed(
                title = "Missao Rank D",
                description = f'{random.choice(responses)}',
                colour = discord.Colour.blue()
            )
            missionEmbed.add_field(name = 'Recompensa', value = '6.000 - 10.000 :moneybag:\n 11 - 25 **SP**', inline = True)
            missionEmbed.add_field(name = 'Linhas', value = '60', inline = True)
            await ctx.channel.send(embed = missionEmbed)
        else:
            await ctx.send('Os ranks sao E/D!')

因此,如果您使用命令'> mission',则可以为任务(e或d)选择等级,我希望他们每个人都有自己的冷却时间,而不是实际任务的冷却时间命令

1 个答案:

答案 0 :(得分:0)

我认为唯一的方法是将任务命令分成多个不同的命令,然后使用@command.cooldown

但是,如果您真的不想这样做,则可以创建一个函数来检查冷却时间,并将其调用到Mission命令。只是一个建议。试用与时间有关的模块。