S
S
Shonnix2021-01-21 17:23:50
Python
Shonnix, 2021-01-21 17:23:50

What causes an unrecognized token: "{" error?

async def balance(ctx, member: discord.Member = None):
    if member is None:
        await ctx.send(embed = discord.Embed(
            description = f"""Баланс пользователя **{ctx.author}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id = {}").fetchone()[0]} :leaves: **"""))

    else:
        await ctx.send(embed=discord.Embed(
            description= f"""Баланс пользователя **{member}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id = {}").fetchone()[0]} :leaves:**"""))


The error itself:
Ignoring exception in command balance:
Traceback (most recent call last):
File "/home/rkksol/PycharmProjects/pythonProject/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/rkksol/PycharmProjects/pythonProject/bot.py", line 52, in balance
description = f"""Баланс пользователя **{ctx.author}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id = {}").fetchone()[0]} :leaves: **"""))
sqlite3.OperationalError: unrecognized token: "{"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/rkksol/PycharmProjects/pythonProject/venv/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/home/rkksol/PycharmProjects/pythonProject/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/rkksol/PycharmProjects/pythonProject/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: unrecognized token: "{"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-01-21
@bacon

To begin with, stop coding like this, namely, shove everything inside f-strings, then it will be clearer, and it will be easier to look for errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question