Пример #1
0
        public async Task HelpAsync(EventContext e)
        {
            if (e.Arguments.Take(out string arg))
            {
                CommandEvent ev = e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Commands
                                  .FirstOrDefault(x => x.Name.ToLower() == arg.ToString().ToLower());

                if (ev == null)
                {
                    using (var context = new MikiContext())
                    {
                        EmbedBuilder helpListEmbed = new EmbedBuilder();
                        helpListEmbed.Title = e.Locale.GetString("miki_module_help_error_null_header");

                        helpListEmbed.Description = e.Locale.GetString("miki_module_help_error_null_message",
                                                                       await e.EventSystem.GetCommandHandler <SimpleCommandHandler>()
                                                                       .GetDefaultPrefixValueAsync(context, e.Guild.Id));

                        helpListEmbed.Color = new Color(0.6f, 0.6f, 1.0f);

                        API.StringComparison.StringComparer   comparer = new API.StringComparison.StringComparer(e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Commands.Select(x => x.Name));
                        API.StringComparison.StringComparison best     = comparer.GetBest(arg);

                        helpListEmbed.AddField(e.Locale.GetString("miki_module_help_didyoumean"), best.text);

                        await helpListEmbed.ToEmbed()
                        .QueueToChannelAsync(e.Channel);
                    }
                }
                else
                {
                    if (await e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetUserAccessibility(e) < ev.Accessibility)
                    {
                        return;
                    }

                    EmbedBuilder explainedHelpEmbed = new EmbedBuilder()
                                                      .SetTitle(ev.Name.ToUpper());

                    if (ev.Aliases.Length > 0)
                    {
                        explainedHelpEmbed.AddInlineField(
                            e.Locale.GetString("miki_module_general_help_aliases"),
                            string.Join(", ", ev.Aliases));
                    }

                    explainedHelpEmbed.AddField
                    (
                        e.Locale.GetString("miki_module_general_help_description"),
                        e.Locale.HasString("miki_command_description_" + ev.Name.ToLower())
                                                        ? e.Locale.GetString("miki_command_description_" + ev.Name.ToLower())
                                                        : e.Locale.GetString("miki_placeholder_null"));

                    explainedHelpEmbed.AddField(
                        e.Locale.GetString("miki_module_general_help_usage"),
                        e.Locale.HasString("miki_command_usage_" + ev.Name.ToLower())
                                                        ? e.Locale.GetString("miki_command_usage_" + ev.Name.ToLower()) : e.Locale.GetString("miki_placeholder_null"));

                    await explainedHelpEmbed.ToEmbed().QueueToChannelAsync(e.Channel);
                }
                return;
            }

            await new EmbedBuilder()
            {
                Description = e.Locale.GetString("miki_module_general_help_dm"),
                Color       = new Color(0.6f, 0.6f, 1.0f)
            }.ToEmbed().QueueToChannelAsync(e.Channel);

            EmbedBuilder embedBuilder = new EmbedBuilder();

            foreach (Module m in e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Modules.OrderBy(x => x.Name))
            {
                List <CommandEvent> events = m.Events
                                             .Where(x => e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetUserAccessibility(e).Result >= x.Accessibility).ToList();

                if (events.Count > 0)
                {
                    embedBuilder.AddField(m.Name.ToUpper(), string.Join(", ", events.Select(x => "`" + x.Name + "`")));
                }
            }

            await embedBuilder.ToEmbed().QueueToChannelAsync(await e.Author.GetDMChannelAsync(), "Join our support server: https://discord.gg/39Xpj7K");
        }
Пример #2
0
        public async Task HelpAsync(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (!string.IsNullOrEmpty(e.arguments))
            {
                ICommandEvent ev = Bot.instance.Events.CommandHandler.GetCommandEvent(e.arguments);

                if (ev == null)
                {
                    IDiscordEmbed helpListEmbed = Utils.Embed;
                    helpListEmbed.Title       = locale.GetString("miki_module_help_error_null_header");
                    helpListEmbed.Description = locale.GetString("miki_module_help_error_null_message", await Bot.instance.Events.GetPrefixInstance(">").GetForGuildAsync(e.Guild.Id));
                    helpListEmbed.Color       = new Color(1.0f, 0, 0);

                    API.StringComparison.StringComparer   comparer = new API.StringComparison.StringComparer(e.commandHandler.GetAllEventNames());
                    API.StringComparison.StringComparison best     = comparer.GetBest(e.arguments);

                    helpListEmbed.AddField(locale.GetString("miki_module_help_didyoumean"), best.text);

                    await helpListEmbed.SendToChannel(e.Channel);
                }
                else
                {
                    if (Bot.instance.Events.CommandHandler.GetUserAccessibility(e.message) < ev.Accessibility)
                    {
                        return;
                    }

                    IDiscordEmbed explainedHelpEmbed = Utils.Embed
                                                       .SetTitle(ev.Name.ToUpper());

                    if (ev.Aliases.Length > 0)
                    {
                        explainedHelpEmbed.AddInlineField(
                            locale.GetString("miki_module_general_help_aliases"),
                            string.Join(", ", ev.Aliases));
                    }

                    explainedHelpEmbed.AddField(
                        locale.GetString("miki_module_general_help_description"),
                        (locale.HasString("miki_command_description_" + ev.Name.ToLower())) ? locale.GetString("miki_command_description_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null"));

                    explainedHelpEmbed.AddField(
                        locale.GetString("miki_module_general_help_usage"),
                        (locale.HasString("miki_command_usage_" + ev.Name.ToLower())) ? locale.GetString("miki_command_usage_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null"));

                    await explainedHelpEmbed.SendToChannel(e.Channel);
                }
                return;
            }
            IDiscordEmbed embed = Utils.Embed;

            embed.Description = locale.GetString("miki_module_general_help_dm");

            embed.Color = new Color(0, 0.5f, 1);

            await embed.SendToChannel(e.Channel);

            await(await Bot.instance.Events.ListCommandsInEmbedAsync(e.message)).SendToUser(e.Author);
        }
Пример #3
0
        public async Task HelpAsync(EventContext e)
        {
            ArgObject arg = e.Arguments.FirstOrDefault();

            if (arg != null)
            {
                CommandEvent ev = e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Commands.FirstOrDefault(x => x.Name.ToLower() == arg.Argument.ToString().ToLower());

                if (ev == null)
                {
                    EmbedBuilder helpListEmbed = Utils.Embed;
                    helpListEmbed.Title = e.GetResource("miki_module_help_error_null_header");

                    helpListEmbed.Description = e.GetResource("miki_module_help_error_null_message", await e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetPrefixAsync(e.Guild.Id));
                    helpListEmbed.Color       = new Color(0.6f, 0.6f, 1.0f);

                    API.StringComparison.StringComparer   comparer = new API.StringComparison.StringComparer(e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Commands.Select(x => x.Name));
                    API.StringComparison.StringComparison best     = comparer.GetBest(arg.Argument);

                    helpListEmbed.AddField(e.GetResource("miki_module_help_didyoumean"), best.text);

                    helpListEmbed.Build()
                    .QueueToChannel(e.Channel);
                }
                else
                {
                    if (e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetUserAccessibility(e.message) < ev.Accessibility)
                    {
                        return;
                    }

                    EmbedBuilder explainedHelpEmbed = new EmbedBuilder()
                    {
                        Title = ev.Name.ToUpper()
                    };

                    if (ev.Aliases.Length > 0)
                    {
                        explainedHelpEmbed.AddInlineField(
                            e.GetResource("miki_module_general_help_aliases"),
                            string.Join(", ", ev.Aliases));
                    }

                    explainedHelpEmbed.AddField(
                        e.GetResource("miki_module_general_help_description"),
                        (Locale.HasString(e.Channel.Id, "miki_command_description_" + ev.Name.ToLower()))
                                                        ? e.GetResource("miki_command_description_" + ev.Name.ToLower()) : e.GetResource("miki_placeholder_null"));

                    explainedHelpEmbed.AddField(
                        e.GetResource("miki_module_general_help_usage"),
                        (Locale.HasString(e.Channel.Id, "miki_command_usage_" + ev.Name.ToLower()))
                                                        ? e.GetResource("miki_command_usage_" + ev.Name.ToLower()) : e.GetResource("miki_placeholder_null"));

                    explainedHelpEmbed.Build().QueueToChannel(e.Channel);
                }
                return;
            }

            new EmbedBuilder()
            {
                Description = e.GetResource("miki_module_general_help_dm"),
                Color       = new Color(0.6f, 0.6f, 1.0f)
            }.Build().QueueToChannel(e.Channel);


            EmbedBuilder embedBuilder = new EmbedBuilder();

            foreach (Module m in e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Modules.OrderBy(x => x.Name))
            {
                List <CommandEvent> events = m.Events
                                             .Where(x => e.EventSystem.GetCommandHandler <SimpleCommandHandler>().GetUserAccessibility(e.message) >= x.Accessibility).ToList();

                if (events.Count > 0)
                {
                    embedBuilder.AddField(m.Name.ToUpper(), string.Join(", ", events.Select(x => "`" + x.Name + "`")));
                }
            }

            embedBuilder.Build().QueueToUser(e.Author);
        }