【问题标题】:Command taking priority over Submodule group Discord.Net命令优先于子模块组 Discord.Net
【发布时间】:2019-03-14 06:30:42
【问题描述】:

我正在尝试使用组设置一些嵌套命令,但父组的命令似乎具有优先权。

这是我的代码示例。

[Group("foo"), Summary("Testing foo")]
public class TestModule : ModuleBase<SocketCommandContext>
{
    [Group("bar"), Summary("Testing bar")]
    public class TestModTwo : ModuleBase<SocketCommandContext>
    {
        [Command, Summary("bar default command")]
        public async Task Test()
        {
            await Context.Channel.SendMessageAsync("bar default command");
        }
    }

    [Command, Summary("foo default command")]
    public async Task Test()
    {
        await Context.Channel.SendMessageAsync("foo default command");
    }

    [Command, Summary("foo default command with string")]
    public async Task Test(string User)
    {
        await Context.Channel.SendMessageAsync("foo default command with string");
    }
}

运行我的命令w?foo bar 时,我的机器人返回“带有字符串的foo 默认命令”而不是所需的“bar 默认命令”。用字符串注释掉我的测试方法返回了我想要的。有没有办法指定我的嵌套命令,同时仍然能够接受父组命令中的字符串?

【问题讨论】:

    标签: c# discord discord.net


    【解决方案1】:

    您可以通过在内部命令上添加PriorityAttribute 来实现这种行为。这将告诉 Discord.net 首先检查此命令。

    注意:插入PriorityAttribute 的最大数字将首先被检查!

    【讨论】:

      猜你喜欢
      • 2019-05-13
      • 1970-01-01
      • 2021-07-07
      • 2017-03-05
      • 1970-01-01
      • 2019-09-29
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多