Ad

Find() Text Message.content Python Discord

- 1 answer

if message.content.lower().startswith('add'):
    text_in = message.content
    text_out = text_in[text_in.find("(") + 1:text_in.find(")")]

I would like to just write "add 500" instead of typing "add (500)" how would that command be? If you have a complete answer, I'll put the answer as your best choice.

Ad

Answer

There's not a great amount of detail in your question, but if we assume that message.content contains a string like "add(500)", then your existing code would place the string "500" in text_out.

To do the same thing where message.content looks like "add 500", you could split message.content by whitespace (.split()), then inspect the second element ([1]):

if message.content.lower().startswith('add'):
    text_out = message.content.split()[1]
Ad
source: stackoverflow.com
Ad