I started learning python recently and don’t understand how to make a cooldown for a command.I need the user to get coins every 12 hours. If the time has not passed yet, I need to display the remaining time.
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)