Search code examples
pythondiscordpycord

Pycord: Slash command sharing a name with a slash command group?


Is there any way to have a slash command sharing a name with a slash command group? I want to be able to have a command /settings that will list the current settings, but also have commands like /settings offset and /settings channel to alter these settings.

I currently have a cog with

    @commands.slash_command()
    async def settings(self, ctx: discord.ApplicationContext):
        """See the settings for this server"""

    settings_group = discord.commands.SlashCommandGroup("settings", "Change the settings for this server")

    @settings_group.command()
    async def offset(self, ctx: discord.ApplicationContext, offset: int):
        """Set the UTC offset for this server"""

    @settings_group.command()
    async def channel(self, ctx: discord.ApplicationContext, channel):
        """Set the reminder channel for this server"""

but attempting to run the bot with this cog gives the error

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 4: Application command names must be unique

Is there a way to work around this using Pycord? Thanks!


Solution

  • This is a Discord Limitation

    Currently, it is not possible to invoke a base command in a Slash Command Group due to a Discord limitation. This would thus translate to the Bad Request Error as well.

    Using subcommands or subcommand groups will make your base command unusable. You can't send the base /permissions command as a valid command if you also have /permissions add | remove as subcommands or subcommand groups

    Docs