B
B
BrenLike2020-08-06 11:23:20
Python
BrenLike, 2020-08-06 11:23:20

Very strange error in Discord.py related to "ctx"?

Only 2 commands do not work for me, the rest all work.

The code:

@client.command(aliases= config['aliases']['repl'])
@commands.has_any_role(config['role']['bankir'])
async def repl(ctx, member:discord.Member=None, count:int):
    author = ctx.message.author
    server = ctx.message.guild
    mentioned = member
    cursor.execute(f'UPDATE users ADD cash = {count} WHERE (id == {mentioned.id})')
    emb = discord.Embed(title= 'Успешно', description= f'На баланс пользавателя {mentioned.mention},\nНачисленно {count} порох(а).', colour=0xE13923)
    await ctx.send(content=f'{author.mention}', embed=emb)

@client.command(aliases=config['aliases']['send'])
@commands.has_any_role(config['role']['client'])
async def send(ctx, member:discord.Member=None, count:int):
    mentioned = member
    author = ctx.message.author
    server = ctx.message.guild
    if cursor.execute(f'SELECT id FROM users WHERE id == {mentioned.id}').fetchone() is None:
        emb = discord.Embed(title= 'Ошибка', description= 'Такого участника нету в базе данных!\nНаверное он не создавал себе аккаунт.', colour= 0xE13923)
        emb.set_footer(text = f"г.{server.name}", icon_url = f'{server.icon_url}')
        await ctx.send(content=f'{author.mention}', embed=emb)
    else:
        if count > 14:
            emb = embed(title= 'Успешно!', description= f'На счёт пользователя {mentioned.mention}\n**Переведенно** `{count}` **порох(а) с вашего счёта.**\nn**Комиссия: 2 порох(а)\n**Ваш баланс составляет** `{balance}` **порох(а)**', colour= 0xB7E10D)
            emb.set_footer(text = f"г.{server.name}", icon_url = f'{server.icon_url}')
            await ctx.send(content=f'{author.mention}', embed=emb)
        else:
            emb = embed(title= 'Успешно!', description= f'На счёт пользователя {mentioned.mention}\n**Переведенно** `{count}` **порох(а) с вашего счёта.**\n\n**Комиссия: 0 порох(а)\n**Ваш баланс составляет** `{balance}` **порох(а)**', colour= 0xB7E10D)
            emb.set_footer(text = f"г.{server.name}", icon_url = f'{server.icon_url}')
            await ctx.send(content=f'{author.mention}', embed=emb)


Mistake:
File "main.py", line 49
    async def repl(ctx, member:discord.Member=None, count:int):
                   ^
SyntaxError: non-default argument follows default argument

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2020-08-06
@BrenLike

Because you first need to learn python, and then write bots. The text of the error clearly says what the problem is and the problem here is not in ctx, but in general in the function signature

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question