'DISCORD BOT How to search and replace a url and getting the discord input
How do I make my discord bot take any input on a player that says +search debuunked
and when I said that It will add debuunked in the last URL here:
https://www.facebook.com/ I want debuunked to be added after the slash, Kindly Help me Thanks :) USING DISCORD.PY
if message.content == '+search' + "%s" + str(message):
await message.channel.send(f"https://www.facebook.com/{message}")
This is my code ^^
Solution 1:[1]
EDIT: You can use the following code if you want to check if the message starts with '+search '
What this code does is using the startswith function. This function identifies when a string initial characters match the ones you introduce as parameters.
Then, once it is checked positively, using message.content.replace('+search ','') what you do is to substitute the string for an empty space, that way you only keep everything that is in message.content except for the initial string.
if message.content.startswith('+search '):
await message.channel.send(f"https://www.facebook.com/{message.content.replace('+search ','')}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
