#Is it possible to register subcommands from a list defined in the program?

1 messages · Page 1 of 1 (latest)

wheat abyss
#

oh wow

#

3 mouth

warped palm
#

I have a list of settings I would like to make subcommands for but I'd rather not type out each one and have to make a new function every time I want to add a setting. I already have a system for taking in a setting name and running all the related things, so I just want to register /config [name] [option] for each setting. I've been able to do this with normal commands outside of a cog, but I can't figure out how to do it inside of a cog and with subcommands.
I tried this, but it raises a ValidationError when I try to run it.

config = SlashCommandGroup(name='config', description='Configuration commands', guild_ids=[...])

    for setting in DEFAULT_SETTINGS:
        @config.command(name=setting, description=SETTINGS_DESCRIPTIONS[setting])
        async def config_command(self, ctx, param1, param2):
            setting_name = ctx.command.qualified_name()  # Figure out which command was called because they'd all run the same function
            ...etc etc

Any help would be appreciated