简体   繁体   中英

How do I make groups for commands in discord.py and use them in different cogs?

I am working on a bot and I want the commands of the bot to be added to different groups but I don't know how to make group.

Is there a way to make the group in the main bot file and then use it in cogs?

I think you know how to create them with this example.

@client.group(name='system', invoke_without_command=True)
async def system():
    pass


@system.command(name='load')
async def hello_subcommand():
    print('test')

The part of invoke_without_command=True will make sure the commands aren't double executed.

The command in this code would be {prefix}system hello

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM