我试图记录一个命令在一个特定用户上被使用了多少次,然后将它写入一个文件,以便在每次命令被触发时添加到其中。在
这是我要做的命令
@client.command(pass_context=True)
async def boop(ctx):
mentions = ctx.message.mentions
for user in mentions:
await client.say("{} has been Boop'ed!".format(user))
我试图将一个数字连同userid
一起写入一个json文件。在
Tags:
最简单的方法可能是维护一个字典,将用户映射到他们被提到的次数。然后可以使用^{} 将其发送到一个文件。你应该注意到这个比例不是很好。如果您看到自己不断更新这个文件,您应该考虑切换到异步数据库(特别是因为文件写入是一个阻塞操作)。在
相关问题 更多 >
编程相关推荐