DisnakeDev / disnake

An API wrapper for Discord written in Python.
https://docs.disnake.dev
MIT License
722 stars 138 forks source link

Slash command sub command group missing required positional arguement #302

Closed MonkeeMan1 closed 2 years ago

MonkeeMan1 commented 2 years ago

Summary

After trying to make a series of commands under a sub command group I ran into an issue regarding the group asking for positional arguments which it shouldn't require

Reproduction Steps

class ConfigCommands(commands.Cog): def init(self, client: commands.Bot): self.client = client

@commands.slash_command(description="Holds all of the fun commands inside")
async def config(self, inter):
    pass

@config.sub_command(description="Adds the verification role")
async def add_roles(
    self, interaction: disnake.GuildCommandInteraction, role: disnake.Role
):
    await interaction.response.defer()
    return await add_roles(self.client, interaction, role)

@config.sub_command(description="Removes the verification role")
async def remove_roles(self, interaction: disnake.GuildCommandInteraction):
    await interaction.response.defer()
    return await remove_roles(self.client, interaction)

@config.sub_command_group()
async def panel(self):
    pass

@panel.sub_command(description="Setup the verification panel")
async def set(
    self, interaction: disnake.GuildCommandInteraction, channel: disnake.TextChannel
):
    await interaction.response.defer()
    return await set_panel(self.client, interaction, channel)

@panel.sub_command(description="Remove the verification panel")
async def remove(self, interaction: disnake.GuildCommandInteraction):
    await interaction.response.defer()
    return await remove_panel(self.client, interaction)

def setup(client): client.add_cog(ConfigCommands(client))

Minimal Reproducible Code

No response

Expected Results

The expected result is for it to not error when I run the commands under the panel sub command group.

Actual Results

Traceback (most recent call last):
  File "F:\Comissions\Monkee\lib\site-packages\disnake\client.py", line 515, in _run_event
    await coro(*args, **kwargs)
  File "F:\Discord Bots\Monkee\cogs\error_handler.py", line 50, in on_slash_command_error
    raise error
  File "F:\Comissions\Monkee\lib\site-packages\disnake\ext\commands\base_core.py", line 285, in invoke
    await self(inter, *args, **kwargs)
  File "F:\Comissions\Monkee\lib\site-packages\disnake\ext\commands\base_core.py", line 188, in __call__
    return await self.callback(self.cog, interaction, *args, **kwargs)
TypeError: ConfigCommands.panel() takes 1 positional argument but 2 were given

Intents

messages, guilds, members, reactions, bans

System Information

Checklist

Additional Context

After asking in the support discord I was told to make a bug report here.

EQUENOS commented 2 years ago

async def panel(self) is missing 1 positional argument representing the interaction. async def panel(self, inter) should work. Let me know if this solves your problem.

MonkeeMan1 commented 2 years ago

this fixed it, thank you :)