M
M
Mem13882021-06-16 21:20:27
Python
Mem1388, 2021-06-16 21:20:27

Why is Discord complaining about quotes?

Let's say I want to send text like this: 1, 2, 3, "4, 5", "6.
I'll do it like this:

@Bot.command()
async def say(ctx, channel: Optional[discord.TextChannel], *, args: str):
    if channel is None:
        await ctx.send(args)
    else:
        await channel.send(args)

But if I want to send an Embed message from JSON data:
def get_embed(json_):
    embed_json = json.loads(json_)

    embed = Embed().from_dict(embed_json)
    return embed

@Bot.command()
async def say(ctx, channel: Optional[discord.TextChannel], *, args: str):
    emb = get_embed(args)
    if channel is None:
        await ctx.send(embed = emb)
    else:
        await channel.send(embed = emb)

, then I get an error
discord.ext.commands.errors.UnexpectedQuoteError: Unexpected quote mark, '"', in non-quoted string

How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dream, 2021-06-16
@Mem1388

You cannot insert double or normal quotes if they already exist.
Example: if quotes are the beginning and end of the text, then you can put normal quotes there: "1, 2, 3, '4', '5', '6'"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question