コード例 #1
0
        public async Task HelpAsync([Summary("The command to get information about."), Remainder] string command = null)
        {
            if (command == null) //run cmds command
            {
                await _commands.Commands.Where(x => x.Name == "commands").First().ExecuteAsync(Context, ParseResult.FromSuccess(new List <TypeReaderValue> {
                    new TypeReaderValue(null, 1f)
                }, new List <TypeReaderValue>()), _services);

                return;
            }

            var cmds = _commands.Commands.Where(x => ((string.IsNullOrEmpty(x.Module.Group) ? "" : $"{x.Module.Group} ") + x.Name).TrimEnd(' ') == command);

            if (cmds.Any())
            {
                var msg = await _inter.SendPaginatorAsync(_misc.GenerateCommandInfo(cmds, Context.User as SocketGuildUser).Build(), Context.Channel);

                if (msg.IsCanceled)
                {
                    await msg.Message.DeleteAsync();
                }
            }
            else
            {
                var split = command.Split(' ');

                var aliases = _commands.Commands.Where(x => ((x.Module.Group == null && split.Length < 2) ||
                                                             x.Module.Group == split[0]) &&
                                                       x.Aliases.Any(y => y == command || (split.Length > 1 && y == split[1]
                                                                                           )));

                if (aliases.Any())
                {
                    var msg = await _inter.SendPaginatorAsync(_misc.GenerateCommandInfo(aliases, Context.User as SocketGuildUser).Build(), Context.Channel);

                    if (msg.IsCanceled)
                    {
                        await msg.Message.DeleteAsync();
                    }
                }
                else
                {
                    await ReplyAsync("This command does not exist.");
                }
            }
        }