Beispiel #1
0
        public async Task SendCommandHelp([Remainder] string commandName)
        {
            CommandInfo command = Commands.Commands.FirstOrDefault(c => c.Aliases.Contains(commandName));

            if (command == null)
            {
                await ReplyAsync($"Can't find a command with that name. Use `{Prefix}help` for a list of commands.");

                return;
            }

            var helpInfo = new CommandHelpInfo(command);


            var embed = new EmbedBuilder
            {
                Title = $"__Command__: {Prefix}{command.Name}",
                Color = Colors.PacManYellow
            };

            if (helpInfo.Hidden)
            {
                embed.AddField("Hidden command", "*Are you a wizard?*", true);
            }

            if (helpInfo.Parameters != "")
            {
                embed.AddField("Parameters", helpInfo.Parameters, true);
            }

            if (command.Aliases.Count > 1)
            {
                string aliasList = "";
                for (int i = 1; i < command.Aliases.Count; i++)
                {
                    aliasList += $"{", ".If(i > 1)}{Prefix}{command.Aliases[i]}";
                }
                embed.AddField("Aliases", aliasList, true);
            }

            if (helpInfo.Summary != "")
            {
                foreach (string section in helpInfo.Summary
                         .Replace("{prefix}", Prefix)
                         .Split("\n\n\n"))
                {
                    embed.AddField("Summary", section + "ᅠ");
                }
            }

            if (helpInfo.ExampleUsage != "")
            {
                embed.AddField("Example Usage", helpInfo.ExampleUsage.Replace("{prefix}", Prefix));
            }

            await ReplyAsync(embed);
        }
Beispiel #2
0
        public async Task SendAllHelp(bool showRemarks)
        {
            var embed = new EmbedBuilder()
            {
                Title       = $"{CustomEmoji.PacMan} __**Bot Commands**__",
                Description = (Prefix == "" ? "No prefix is needed in this channel!" : $"Prefix for this server is '{Prefix}'")
                              + $"\nYou can do **{Prefix}help command** for more information about a command.\n\n"
                              + $"Parameters: [optional] <needed>",
                Color = Colors.PacManYellow
            };

            foreach (var module in Commands.Modules.OrderBy(m => m.Remarks))
            {
                var moduleText = new StringBuilder();

                foreach (var command in module.Commands.OrderBy(c => c.Priority))
                {
                    var helpInfo = new CommandHelpInfo(command);

                    if (!helpInfo.Hidden)
                    {
                        var conditions = await command.CheckPreconditionsAsync(Context);

                        if (!conditions.IsSuccess)
                        {
                            continue;
                        }

                        moduleText.Append($"**{command.Name} {helpInfo.Parameters}**");
                        if (showRemarks && helpInfo.Remarks != "")
                        {
                            moduleText.Append($" — *{helpInfo.Remarks}*");
                        }
                        moduleText.Append('\n');
                    }
                }

                if (!showRemarks && module.Name.Contains("Pac-Man"))
                {
                    moduleText.Append("**bump**\n**cancel**\n");
                }

                if (moduleText.Length > 0)
                {
                    embed.AddField(module.Name, moduleText.ToString(), true);
                }
            }

            await ReplyAsync(embed);
        }