Beispiel #1
0
        private static string?GetHelp(IGuild guild, string commandStr, Permissions permissions)
        {
            StringBuilder  builder  = new StringBuilder();
            List <Command> commands = CommandsService.GetCommands(commandStr);

            int count = 0;

            foreach (Command command in commands)
            {
                // Don't show commands users cannot access
                if (command.Permission > permissions)
                {
                    continue;
                }

                count++;
            }

            if (count <= 0)
            {
                return(null);
            }

            builder.Append("__");
            ////builder.Append(CommandsService.CommandPrefix);
            builder.Append(commandStr);
            builder.AppendLine("__");

            foreach (Command command in commands)
            {
                // Don't show commands users cannot access
                if (command.Permission > permissions)
                {
                    continue;
                }

                builder.Append(Utils.Characters.Tab);
                builder.Append(command.Permission);
                builder.Append(" - *");
                builder.Append(command.Help);
                builder.AppendLine("*");

                List <ParameterInfo> parameters = command.GetNeededParams();

                builder.Append("**");
                builder.Append(Utils.Characters.Tab);
                builder.Append(CommandsService.GetPrefix(guild));
                builder.Append(commandStr);
                builder.Append(" ");

                for (int i = 0; i < parameters.Count; i++)
                {
                    if (i != 0)
                    {
                        builder.Append(" ");
                    }

                    builder.Append(GetParam(parameters[i], command.RequiresQuotes));
                }

                builder.Append("**");
                builder.AppendLine();
                builder.AppendLine();
            }

            return(builder.ToString());
        }
Beispiel #2
0
        public static async Task <bool> GetHelp(CommandMessage message, Permissions permissions)
        {
            EmbedBuilder  embed   = new EmbedBuilder();
            StringBuilder builder = new StringBuilder();

            List <string> commandStrings = new List <string>(CommandsService.GetCommands());

            commandStrings.Sort();

            int commandCount = 0;

            foreach (string commandString in commandStrings)
            {
                if (commandString == "help")
                {
                    continue;
                }

                int            count    = 0;
                List <Command> commands = CommandsService.GetCommands(commandString);
                foreach (Command command in commands)
                {
                    if (command.Permission > permissions)
                    {
                        continue;
                    }

                    count++;
                }

                if (count <= 0)
                {
                    continue;
                }

                builder.Append("__");
                builder.Append(commandString);
                builder.Append("__ - *+");
                builder.Append(count);
                builder.Append("* - ");
                builder.Append(commands[0].Help);
                builder.AppendLine();

                commandCount++;

                if (commandCount >= 20)
                {
                    embed             = new EmbedBuilder();
                    embed.Description = builder.ToString();
                    await message.Channel.SendMessageAsync(null, false, embed.Build());

                    builder.Clear();
                    commandCount = 0;
                }
            }

            builder.AppendLine();
            builder.AppendLine();
            builder.AppendLine("To get more information on a command, look it up directly, like `" + CommandsService.GetPrefix(message.Guild) + "help \"time\"` or `" + CommandsService.GetPrefix(message.Guild) + "et ?`");

            embed             = new EmbedBuilder();
            embed.Description = builder.ToString();
            await message.Channel.SendMessageAsync(null, false, embed.Build());

            return(true);
        }