How do I ask a user to output in a predefined time format in slash commands, like in this bot, it is asking user to type time like 1m(for 1 minute) 3w(for 3 weeks, etc), I have searched everywhere for this but I found nothing about this and I have no idea on how to do it.
1 Answer
Im pretty sure you can use .endswith() something like this:
if length.endswith(“m”):
length = length[:-1]
length = int(length) # now you have an int amount of the minutes and you can do:
length / 60 # for hours etc
length * 60 # for seconds
if length.endswith(“w”):
length = int(length[:-1]) # idk if this will work but if not just use a second line to convert to int like the example for minutes
length = length * 604800 # for seconds
You didnt specify what you’ll be using so imma assume your converting everything to seconds but if not just change the code for that
