不一致错误“未知命令”。

时间:2018-08-24 07:16:11

标签: c# command bots discord

[Command("say"), Summary("Echo a message.")]
    public async Task Say([Remainder, Summary("The text to echo")] string echo)
    {
        // ReplyAsync is a method on ModuleBase

        Console.WriteLine(echo);
        await ReplyAsync(echo);
    }

    [Command("square"), Summary("Squares a number.")]
    public async Task Square([Summary("The number to square.")] int num)
    {
        // We can also access the channel from the Command Context.
        await Context.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}");
    }

    // ~sample userinfo --> foxbot#0282
    // ~sample userinfo @Khionu --> Khionu#8708
    // ~sample userinfo Khionu#8708 --> Khionu#8708
    // ~sample userinfo Khionu --> Khionu#8708
    // ~sample userinfo 96642168176807936 --> Khionu#8708
    // ~sample whois 96642168176807936 --> Khionu#8708
    [Command("userinfo"), Summary("Returns info about the current user, or the user parameter, if one passed.")]
    [Alias("user", "whois")] //sub Command ~user, ~whois
    public async Task UserInfo([Summary("The (optional) user to get info for")] IUser user = null)
    {
        var userInfo = user ?? Context.Client.CurrentUser;
        await ReplyAsync($"{userInfo.Username}#{userInfo.Discriminator}");
    }

    [Command("ping")]
    public async Task PingAsync()
    {
       // await ReplyAsync($"{Context.Client.CurrentUser.Mention} || {Context.User.Mention} sent {Context.Message.Content} in {Context.Guild.Name}!");
        await ReplyAsync($"{Context.Client.CurrentUser} || {Context.User.Mention} sent {Context.Message.Content} in {Context.Guild.Name}!");
    }


    [Command("help")]
    public async Task HelpAsync()
    {
        EmbedBuilder builder = new EmbedBuilder();

        builder.AddField("!say", "Output the message you sent");
        builder.AddField("!square", "Squares the number");
        builder.AddField("Field3", "test");
        await ReplyAsync("", false, builder.Build());
    }

///我使用了Google翻译。 我观看了YouTube视频并编写了代码。但是,视频中没有错误。 但是,除“ ping:”以外的其他命令不会发送错误消息。 当我运行代码时,我得到一个error message。 我不知道为什么。 :(

error message

0 个答案:

没有答案
相关问题