示例#1
0
        public async Task HelpCommand([Remainder] string command = null)
        {
            var AvailableCommands = new List <Command>();

            foreach (Command c in Core.Commands)
            {
                if (c.Listed == false)
                {
                    continue;
                }
                else if (c.Rank > await MiXLib.GetRank(Context.User.Id, Context.Guild))
                {
                    continue;
                }
                else if (c.Guild != 0 && c.Guild != Context.Guild.Id)
                {
                    continue;
                }
                AvailableCommands.Add(c);
            }
            if (command == null)
            {
                await ReplyAsync("", false, MiXLib.GetEmbed(
                                     $"Rank: **{MiXLib.GetRankName(await MiXLib.GetRank(Context.User.Id, Context.Guild))}**\n" +
                                     $"Available Commands (**{AvailableCommands.Count.ToString()}**): {(new Func<string>(() => { var cmds = new List<string>(); foreach (Command c in AvailableCommands) cmds.Add(c.Name); return MiXLib.Concat(cmds, ", ", "**", "**"); }))()}\n\n" +
                                     $"Run **{Core.Guilds[Context.Guild.Id].Config.Prefix}help <command>** for more info"));
            }
            else
            {
                var Command = Core.GetCommand(command);
                if (Command == null || Command.Listed == false || (Command.Guild != 0 && Command.Guild != Context.Guild.Id))
                {
                    await ReplyAsync("", false, MiXLib.GetEmbed($"**Error**: Could not find command **{command}**.", null, new Color(200, 0, 0)));

                    return;
                }
                await ReplyAsync("", false, MiXLib.GetEmbed(
                                     $"Command Name: **{Command.Name}**\n" +
                                     $"Description: **{Command.Description}**\n" +
                                     $"Aliases: {MiXLib.Concat(Command.Aliases, ", ", "**", "**")}\n" +
                                     $"Usage: **{Command.Usage}**\n" +
                                     $"Minimum Rank: **{MiXLib.GetRankName(Command.Rank)}**\n" +
                                     $"User can run: **{MiXLib.BoolToYesNo(await MiXLib.GetRank(Context.User.Id, Context.Guild) >= Command.Rank)}**"
                                     ));
            }
        }