Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 跟踪在discord.py中使用命令的次数_Python 3.x_Discord_Discord.py - Fatal编程技术网

Python 3.x 跟踪在discord.py中使用命令的次数

Python 3.x 跟踪在discord.py中使用命令的次数,python-3.x,discord,discord.py,Python 3.x,Discord,Discord.py,我一直在试图找出如何跟踪用户使用命令的次数。我希望能够递增并显示每次键入命令时使用该命令的次数。 以下是我对一个命令的一些代码: 忽略选择语句 @client.command(pass_context=True) async def pick(ctx): author = ctx.message.author.id if 1 <= giftRate <= 2: if (1 <= lowFishRange <= 20):

我一直在试图找出如何跟踪用户使用命令的次数。我希望能够递增并显示每次键入命令时使用该命令的次数。 以下是我对一个命令的一些代码: 忽略选择语句

@client.command(pass_context=True)
async def pick(ctx):
    author = ctx.message.author.id
    if 1 <= giftRate <= 2:
        if (1 <= lowFishRange <= 20):
            oneto5 = str(5)
            await client.say("<@%s>" % (author) + " recived " + oneto5 + " 
            fish")

        else:
            oneto5 = str(1)
            await client.say("<@%s>" % (author) + " recived " + oneto5 + " 
            fish")
     else:
        await client.say("<@%s>" % (author) + " seemed to have missed the mark, the only way to gurantee fish is by "
                     "waiting for a cool pant cate to give you some.")
@client.command(pass\u context=True)
异步def拾取(ctx):
author=ctx.message.author.id

如果1你可以有一个全球词典来跟踪它。键是用户id,值是他们执行特定命令的次数。您需要多个字典,每个命令一个字典,或者您可以让dict值成为一个列表,每个索引都有不同命令的计数

commandCounts = {}
commandCounts[user.id] = [command1, command2, command3]