我正在尝试使用Give命令制作积分系统,例如,如果用户完成了挑战,那么mod可以给用户积分,我已经为它编写了一个函数来写入用户ID(以及当它们加入时(第一个方框),应该将点添加到JSON中),但是我似乎无法正确地获得Give命令(第二个方框),我们将不胜感激,在此先感谢:)
async def update_data(users, user): #i called this in the member join event
if not user.id in users:
users[user.id] = {}
users[user.id]['points'] = []
这是用户登录的日志,这是Give命令:
@client.command(pass_context = True)
async def give(ctx, member, amount):
async def add_points(users, member, amount):
for user in users:
if user['id'] == member.id:
user['points'] += amount
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, member)
await add_points(users, member, amount)
with open('users.json', 'w') as f:
json.dump('users', 'f')