简体   繁体   English

Pycord:斜杠命令与斜杠命令组共享名称?

[英]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.我希望能够有一个命令/settings来列出当前设置,但也有像/settings offset/settings channel这样的命令来改变这些设置。

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但是尝试使用此 cog 运行机器人会出现错误

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?有没有办法使用 Pycord 解决这个问题? Thanks!谢谢!

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.目前,由于 Discord 限制,无法在 Slash 命令组中调用基本命令。 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 |如果您还有 /permissions add | 则不能将基本 /permissions 命令作为有效命令发送。 remove as subcommands or subcommand groups作为子命令或子命令组删除

Docs 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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