Issue
I have this command:
if message.content.lower().startswith("!activate"):
if message.author.id not in tempo:
await Bot.send_message(message.channel, "{} used the command".format(message.author.name))
tempo.append(message.author.id)
await asyncio.sleep(720)
tempo.remove(message.author.id)
else:
await Bot.send_message(message.channel, "wait {} hours.".format(asyncio.sleep))
I would like every time the person tried to use the command a second time, show how much time is left before they can use it again, something like: "wait 4 hours and 50 minutes."
what should I do?
Solution
You can just store the time and calculate the remaining yourself:
import time
tempo = {} # use a dict to store the time
if message.content.lower().startswith("!activate"):
if message.author.id not in tempo:
await Bot.send_message(message.channel, "{} used the command".format(
message.author.name))
tempo[message.author.id] = time.time() + 720 # store end time
await asyncio.sleep(720)
del tempo[message.author.id]
else:
await Bot.send_message(message.channel, "wait {} seconds.".format(
tempo[message.author.id] - time.time()))
Answered By - nosklo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.