如何制作一个带有空格的斜杠命令,以“分类”命令?

huangapple go评论109阅读模式
英文:

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 /&lt;category&gt; &lt;command&gt; &lt;arguments (if necessary)&gt; , 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=&quot;category1&quot;, description=&quot;Description for category1 commands&quot;)

@group.command()
async def subcommand(interaction):
    ...


@group.command()
async def subcommand2(interaction):
    ...


tree.add_command(group)

huangapple
  • 本文由 发表于 2023年5月28日 02:18:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348386.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定