pycord icon indicating copy to clipboard operation
pycord copied to clipboard

Cog slash commands default option doesn't work as intended

Open Sollisnexus opened this issue 5 years ago • 2 comments

Summary

flag isn't working as intended in cogs

Reproduction Steps

Ran the code snippet below in a cog and ran the /sprite command without adding form option (since it's optional)

Minimal Reproducible Code

    @slash_command(name='sprite', description="Displays the Pokemon's Home sprite")
    @option('shiny', str, description='You want shiny sprite or normal?', choices=["Normal","Shiny"], required=True)
    @option('name', str, description="Name of Pokemon", required=True)
    @option('form', str, description="Any regional/unique form?", required=False, default="None")
    async def _sprite_slash(self, ctx: ApplicationContext, shiny: str, name: str, form: str):       
        print(shiny)
        print(form)
        print(name)
        await ctx.respond("The input is recieved")

Expected Results

Expected default to fill in form with the default value if nothing was entered

Actual Results

Ignoring exception in command <discord.app.commands.SlashCommand name=sprite>: Traceback (most recent call last): File "C:....\anaconda3\envs\pycordalpha\lib\site-packages\discord\app\commands.py", line 93, in wrapped ret = await coro(*args, **kwargs) TypeError: _sprite_slash() missing 1 required positional argument: 'form'

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

Traceback (most recent call last): File "C:....\anaconda3\envs\pycordalpha\lib\site-packages\discord\bot.py", line 227, in process_application_commands await ctx.command.invoke(ctx) File "C:....\anaconda3\envs\pycordalpha\lib\site-packages\discord\app\commands.py", line 199, in invoke await injected(*self.args, **self.kwargs) File "C:....\anaconda3\envs\pycordalpha\lib\site-packages\discord\app\commands.py", line 99, in wrapped raise ApplicationCommandInvokeError(exc) from exc discord.app.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: _sprite_slash() missing 1 required positional argument: 'form'

Intents

defaults

System Information

  • Python v3.8.11-final
  • pycord v2.0.0-alpha
    • pycord pkg_resources: v2.0.0a3974+g35a1364c
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19043

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

No response

Sollisnexus avatar Sep 13 '21 06:09 Sollisnexus

Not sure if anything changed between now and 7 days ago but there is no error (using the slash branch) now

ufywufy avatar Sep 20 '21 01:09 ufywufy

Yep just tested it now and it works as intended.

Sollisnexus avatar Sep 25 '21 18:09 Sollisnexus