#Got multiple values for argument

1 messages · Page 1 of 1 (latest)

fringe gale
#

So I have this function for my bot:

@slash_command(name="generate", description="Let the bot continue a text based on discord messages it has seen")
@slash_option(name="model", description="Which model should be used", opt_type=OptionType.STRING, required=True,
              choices=[SlashCommandChoice("markovDC-5", "markovDC-5"), SlashCommandChoice("markovDC-10", "markovDC-10")])
@slash_option(name="context", description="Text the bot will try to continue", opt_type=OptionType.STRING, required=True)
@slash_option(name="amount", description="Amount of tokens the model will generate (may be lower if it can't continue)", opt_type=OptionType.INTEGER, required=True)
@slash_option(name="seed", description="A seed for the randomizer. The same seed with the same context will yield the same output", opt_type=OptionType.INTEGER, required=False)
@slash_option(name="highlighting", description="Highlighting for the generated output. Only use for fun", opt_type=OptionType.STRING, required=False)
@slash_option(name="combine", description="Wether to combine the prompt and output into one text block", opt_type=OptionType.BOOLEAN, required=False)
async def generate(ctx: SlashContext, model: str, context: str, amount: int,
                   seed: int = None, highlighting: str = None, combine=False):
    print(ctx, model, context, amount, seed, highlighting, combine)

    # (the rest of the command logic)

The function worked a few days ago until I made some modifications to it's contents and suddenly I get an error. All my other commands work just fine. This one doesn't for some reason. The print statement was added while trying to debug but nothing is printed because the function fails while being called.

charred needleBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

fringe gale
#

This is the error:

Ignoring exception in cmd `/generate`:
Traceback (most recent call last):
  File "/home/jw/PycharmProjects/Lumos/.venv/lib/python3.10/site-packages/interactions/client/client.py", line 1900, in __dispatch_interaction
    response = await callback
  File "/home/jw/PycharmProjects/Lumos/.venv/lib/python3.10/site-packages/interactions/client/client.py", line 1771, in _run_slash_command
    return await command(ctx, **ctx.kwargs)
TypeError: BaseCommand.__call__() got multiple values for argument 'context'
calm mica
#

yeah... naming an option context tends to mess the library up, and i cant really do much about it without it being breaking

#

you can work around it by using the argument_name thing in your option declarations (and, naturally, naming your argument something different than context)