Ad
Find() Text Message.content Python Discord
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
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad