我最近开始学习python,但不了解如何对命令进行冷却。我需要用户每12小时获取硬币。如果时间还没有过去,我需要显示剩余时间。
import datetime
import json
def save_data(users):
with open('files/users_info.json','w') as f:
json.dump(users,f)
async def add_money(users,user,money):
users[str(user.id)]['money'] += money
@commands.command(name='daily')
async def daily(self,ctx):
with open('files/users_info.json','r') as f:
users = json.load(f)
# timer...
#
# if time >= 43200 (seconds)
# await add_money(users,ctx.author,1000)
# await ctx.send('Gave 1000 coins')
# else:
# hours...
# min...
# sec...
# await ctx.send(f'Left {hours},{min},{sec}')
save_data(users)