0

I'm trying to make a command as always but i cannot use them with a space in between. This is my code at the moment.

@client.command()
async def cautionsign(ctx, msg):
  embed = discord.Embed(title="Here's your caution sign!")
  embed.set_image(url=f"https://api.popcat.xyz/caution?text={msg}")
  await ctx.send(embed=embed)

For ex if i use

!cautionsign test

it will show a cautionsign with test on it but if i use

!cautionsign test test

it will just show test.

If anyone can help me i'd appreciate it :)

2
  • Use the replace method, doing the following your request will work as expected. msg.replace(' ', "%20"). Commented Jun 19, 2022 at 22:20
  • Yeah that also works Commented Jun 19, 2022 at 22:55

1 Answer 1

0

try using the urllib.parse.quote to properly escape url components. For example...

from urllib.parse import quote
embed.set_image(url=f"https://api.popcat.xyz/caution?text={quote(msg)}")
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you I tried to do the same thing but i used "{urllib.parse.quote(msg)}" instead of "{quote(msg)}"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.