0

enter image description here

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 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.