Exemplo n.º 1
0
        public async Task <RuntimeResult> PrintHelp([Optional] string commandOrModule)
        {
            StringBuilder sb = new StringBuilder();
            string        footerText;

            if (commandOrModule == null)
            {
                foreach (var mod in _commands.Modules.Where(m => m.Parent == null))
                {
                    sb.Append(HelpBuilder.BuildGeneralModuleDescription(mod));
                    sb.Append(Environment.NewLine);
                }
                footerText = "Use 'help <module name>' for a list of commands of this module (case insensitive).";
            }
            else
            {
                commandOrModule = commandOrModule.ToLower();
                var probableModule = _commands.Modules.Where(m => m.Name.ToLower().Equals(commandOrModule));
                if (probableModule.Any())
                {
                    sb.Append(HelpBuilder.BuildDetailedModuleDescription(probableModule.First(), Context, _services));
                    footerText = "Use 'help <command name>' for a detailed description of the command.";
                }
                else
                {
                    var probableCommand = _commands.Commands.Where(c => c.Name.ToLower().Equals(commandOrModule));
                    if (probableCommand.Any())
                    {
                        var command = probableCommand.First();
                        sb.Append(HelpBuilder.BuildDetailedCommandDescription(command));
                    }
                    else
                    {
                        sb.Append("No module/command found for that name.");
                    }
                    footerText = "";
                }
            }
            var builder = new EmbedBuilder();

            builder.WithDescription(sb.ToString());
            builder.WithFooter(new EmbedFooterBuilder().WithText(footerText));
            builder.WithTitle("OneplusBot - Help");
            await Context.Channel.SendMessageAsync(embed : builder.Build());

            return(CustomResult.FromIgnored());
        }