英文:
How to make a slash command with spaces, to "categorize" commands?
问题
如何使斜杠命令带有空格?正如您在另一个机器人的此图像中所见,它使用空格来对命令进行分类,格式类似于/<category> <command> <arguments(如果需要的话)>
,同时命令也可以在不使用斜杠的情况下使用,比如/react angry
和!angry
都可以以相同的方式工作。我该如何做类似的事情?
https://i.stack.imgur.com/K8Ywr.png
我尝试使用混合命令,但我还没有能够实现类似的结果。
英文:
How can I make slash commands have spaces? As you can see in this image from another bot, it uses spaces to categorize commands something like /<category> <command> <arguments (if necessary)>
, and at the same time the command can also be used without using slash like /react angry
and just !angry
work the same way. How can I do something like that?
https://i.stack.imgur.com/K8Ywr.png
I tried using hybrid commands, but I haven't been able to achieve a similar result.
答案1
得分: 1
这些是在discord.py
中所谓的“groups”:
from discord.app_commands import Group
group = Group(name="category1", description="Category1命令的描述")
@group.command()
async def subcommand(interaction):
...
@group.command()
async def subcommand2(interaction):
...
tree.add_command(group)
英文:
They're so called "groups" in discord.py
from discord.app_commands import Group
group = Group(name="category1", description="Description for category1 commands")
@group.command()
async def subcommand(interaction):
...
@group.command()
async def subcommand2(interaction):
...
tree.add_command(group)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论