I have a discord bot which has a command that requires a cooldown of a week. I considered using something like @commands.cooldown
, but the issue is that if the bot goes offline, that cooldown resets itself. So, a member could simply watch for when the bot goes down and try to exploit it after it returns.
Since I can't keep the bot running 24x7x365, the solution I came up with was to record the date a user last used the command in a database, and when they use the command next, to check if seven days have passed.
For example's sake, this is what the command would look like:
@bot.command()
async def datetest(ctx,date):
today = datetime.date.today()
print(today)
someday = datetime.date.strptime(date,"%y-%m-%d")
diff = someday - today
await ctx.send(diff + "days.")
In this example, I'm using "date" as a parameter to just test if the command returns the difference of days.
(in the actual command, rather than take a date argument, it'll get a date stored in the DB)
However, the issue I'm facing is that:
someday = datetime.date.strptime(date,"%y-%m-%d")
doesn't run. What am I doing wrong here?