python throws an error on different parts of the code as "invalid syntax"

Question:

I’m writing code for my discord bot on discord.py. At one point, he began to give a "syntax invalid" error for everything, even if he hadn’t done it before.
The last two versions of the code and errors:

@client.command(aliases = ['balance', 'cash', 'money', 'bal', 'бал', 'баланс', 'деньги'])
async def balance(ctx, member: discord.Member = None):
    if member is None:
        await ctx.send(embed = discord.Embed( 
            title = f"""Баланс **{ctx.author}"""
            description = f"""Коины: **{cursor.execute("SELECT cash FROM user WHERE id = {}").format(ctx.author.id).fetchone()[0]}** <:DS_SaphireCoin:1023242850483314710> nОсколки Шизы:**{cursor.execute("SELECT shiza FROM user WHERE id = {}")}** <a:DS_shiza:1023239736061603864>"""
            timestamp = ctx.message.created_at
        ))

and

@client.command(aliases = ['balance', 'cash', 'money', 'bal', 'бал', 'баланс', 'деньги'])
async def balance(ctx, member: discord.Member = None):
    if member is None:
        await ctx.send(embed = discord.Embed( 
            title = f"""Баланс **{ctx.author}"""
            description = f"""Коины: **{cursor.execute("SELECT cash FROM user WHERE id = {}").format(ctx.author.id).fetchone()[0]}** <:DS_SaphireCoin:1023242850483314710>"""
            timestamp = ctx.message.created_at
        ))

in ver 1 error is

PS D:JekaChmonya bot>  d:; cd 'd:JekaChmonya bot'; & 'D:Jekapythonpython.exe' 'c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher' '54767' '--' 'd:JekaChmonya botcommands_user.py'
Traceback (most recent call last):
  File "D:Jekapythonlibrunpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:Jekapythonlibrunpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy__main__.py", line 39, in <module>
    cli.main()
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 430, in main
    run()
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 320, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 294, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "d:JekaChmonya botcommands_user.py", line 16
    description = f"""Коины: **{cursor.execute("SELECT cash FROM user WHERE id = {}").format(ctx.author.id).fetchone()[0]}** <:DS_SaphireCoin:1023242850483314710> nОсколки Шизы:**{cursor.execute("SELECT shiza FROM user WHERE id = {}").fetchone()[0]}** <a:DS_shiza:1023239736061603864>**"""
    ^
SyntaxError: invalid syntax

in ver 2

PS D:JekaChmonya bot>  d:; cd 'd:JekaChmonya bot'; & 'D:Jekapythonpython.exe' 'c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher' '54777' '--' 'd:JekaChmonya botcommands_user.py'
Traceback (most recent call last):
  File "D:Jekapythonlibrunpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:Jekapythonlibrunpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy__main__.py", line 39, in <module>
    cli.main()
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 430, in main
    run()
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 320, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "c:UsersJeKa.vscodeextensionsms-python.python-2022.14.0pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 294, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "d:JekaChmonya botcommands_user.py", line 16
    description = f"""Коины: **{cursor.execute("SELECT cash FROM user WHERE id = {}").format(ctx.author.id).fetchone()[0]}** <:DS_SaphireCoin:1023242850483314710>"""
    ^
SyntaxError: invalid syntax

i dunno how to fix it, pls help

Asked By: itzDezzzix

||

Answers:

As @quamrana said in his comment, I think you’re missing a comma at the end of your function arguments.

@client.command(aliases = ['balance', 'cash', 'money', 'bal', 'бал', 'баланс', 'деньги'])
async def balance(ctx, member: discord.Member = None):
    if member is None:
        await ctx.send(embed = discord.Embed( 
            title = f"""Баланс **{ctx.author}""",
            description = f"""Коины: **{cursor.execute("SELECT cash FROM user WHERE id = {}").format(ctx.author.id).fetchone()[0]}** <:DS_SaphireCoin:1023242850483314710>""",
            timestamp = ctx.message.created_at
        ))

In general, for any function, the comma syntax is as below:

#Example
def hello_world(
                string = "something",
                other_string = "something else",
                x = 1):
    print(string, other_string, x)


hello world(string = "f",
            other_string = "y",
            x = 2)
Answered By: Codeman