I was wondering how I would be able to accept user input from an embedded message like this image does: 
Doesn't have to be exactly like that, but I want a guild member to be able to input information into an embedded message. I haven't been able to find anything about it in Discord.py API
The image shown is embedded message which does not take input but shows the output after taking input from a user as a text form. You can use the code given below:
@bot.event()
async def on_message(message):
if message.author==bot.user:
return
msg = message.content
if msg.startswith("!cal "):
names = msg.split("!cal ",1)[1]
data = names.split("*")
a = data[0]
b = data[1]
c=int(a)*int(b)
r=str(c)
em=discord.Embed(title=f"Calculator",description=f"Input\n```{a}*{b}```\n\nOutput\n```{r}```")
await message.channel.send(embed=em)
You can use this code to show the same result.
NOTE : User must enter the command properly as !cal 5*5
In the Discord API there's no way to accept an user input, but you can do something like this:
ctx.send(embed=discord.Embed(title="Hey", description="Tell me something!"))
msg = Bot.wait_for("message")
ctx.send(embed=discord.Embed(title="You said...", description=msg.content)
If you want some information from the user who used the command, try this:
while True:
msg = Bot.wait_for("message")
if (msg.author == ctx.author):
break
Then, you may like to do something like this:
# Same stuff as before...
result = eval(msg.content)
ctx.send(embed=discord.Embed(title="Result", description=result))
This will work like the calculator you shown in the answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With