Exemple #1
0
        public async Task ListCharactersAsync(CachedMember user)
        {
            var characters = DbContext.Database.Users.FirstOrDefault(u => u.Id == user.Id)?.Characters;

            var embed = new LocalEmbedBuilder()
                        .WithTitle($"{user.DisplayName}'s characters:");

            if (characters is null || !characters.Any())
            {
                embed.WithDescription($"They have no characters.");
                await ReplyAsync(embed : embed.Build());

                return;
            }

            var sb = new StringBuilder();

            foreach (var character in characters)
            {
                sb.AppendLine($"{character.CharacterName} | {character.Class} | {character.Role}");
            }

            embed.WithDescription(sb.ToString());
            await ReplyAsync(embed : embed.Build());
        }
Exemple #2
0
        public async Task ListCharactersAsync()
        {
            var characters = DbContext.User.Characters;

            var embed = new LocalEmbedBuilder()
                        .WithTitle($"{Context.Member.DisplayName}'s characters:");

            if (!characters.Any())
            {
                embed.WithDescription("You have no characters registered. You may do with `!character add NameOfYourToon ClassName Role (Melee|Ranged|Tank|Healer)`");
                await ReplyAsync(embed : embed.Build());

                return;
            }

            var sb = new StringBuilder();

            foreach (var character in characters)
            {
                sb.AppendLine($"{character.CharacterName} | {character.Class} | {character.Role}");
            }

            embed.WithDescription(sb.ToString());
            await ReplyAsync(embed : embed.Build());
        }
Exemple #3
0
        public static LocalEmbedBuilder CreateEmbed(EmbedType type, string title, string content = null)
        {
            LocalEmbedBuilder embed = new LocalEmbedBuilder();

            switch (type)
            {
            case EmbedType.Info:
                embed.WithAuthor(title);
                embed.WithColor(new Color(67, 181, 129));
                break;

            case EmbedType.Success:
                embed.WithAuthor(title, "https://i.imgur.com/XnVa7ta.png");
                embed.WithColor(new Color(67, 181, 129));
                break;

            case EmbedType.Failure:
                embed.WithAuthor(title, "https://i.imgur.com/Sg4663k.png");
                embed.WithColor(new Color(67, 181, 129));
                break;
            }

            embed.WithDescription(content);

            return(embed);
        }
Exemple #4
0
        public async Task TrackerAsync()
        {
            var id          = Context.User.Id;
            var description = $"You are not registered! `c!register` to register.";
            var builder     = new LocalEmbedBuilder()
                              .WithTitle("Tracker template");
            var player = ContrackerService.GetPlayer(discordId: id.ToString());

            if (player != null)
            {
                var contracts = ContrackerService.Contracker.GetPlayerContracts(player);
                if (contracts.Count > 0)
                {
                    description = string.Join("\n",
                                              contracts.Select(x =>
                                                               $"`{x.Contract.Name}` - {x.Contract.Primary.Description}\n" +
                                                               $"\tPoints: {x.Contract.Primary.Points}"));
                }
                else
                {
                    description = "`You have no active contracts!`";
                }
            }
            await ReplyAsync(embed : builder
                             .WithDescription(description)
                             .WithColor(Color.Honeydew)
                             .Build()).ConfigureAwait(true);
        }
Exemple #5
0
        public async Task ProfileAsync()
        {
            var id          = Context.User.Id;
            var color       = Color.Red;
            var description = "You are not registered!";
            var embed       = new LocalEmbedBuilder()
                              .WithTitle("User profile");
            var player = ContrackerService.Contracker
                         .GetPlayer(discordId: id.ToString());

            if (player != null)
            {
                description = "You are gamer.";
                color       = Color.Green;
                var steamname = SteamService.GetSteamName(player.Steam);
                embed.AddField("Discord", Discord.MentionUser(Context.User))
                .AddField("Steam", $"[{steamname}](https://steamcommunity.com/profiles/{player.Steam})")
                .AddField("Total CP", player.Cp)
                .AddField("Stars", player.Stars);
            }

            await ReplyAsync(embed : embed
                             .WithDescription(description)
                             .WithColor(color)
                             .Build()).ConfigureAwait(true);
        }
        public async Task HelpAsync()
        {
            var embed = new LocalEmbedBuilder
            {
                Color  = RiasUtilities.ConfirmColor,
                Author = new LocalEmbedAuthorBuilder
                {
                    Name    = GetText(Localization.HelpTitle, RiasBot.CurrentUser.Name, Rias.Version),
                    IconUrl = RiasBot.CurrentUser.GetAvatarUrl()
                },
                Footer = new LocalEmbedFooterBuilder().WithText("© 2018-2020 Copyright: Koneko#0001")
            };

            embed.WithDescription(GetText(Localization.HelpInfo, Context.Prefix));

            var          links     = new StringBuilder();
            const string delimiter = " • ";

            if (!string.IsNullOrEmpty(Credentials.OwnerServerInvite))
            {
                var ownerServer = RiasBot.GetGuild(Credentials.OwnerServerId);
                links.Append(delimiter)
                .Append(GetText(Localization.HelpSupportServer, ownerServer.Name, Credentials.OwnerServerInvite))
                .Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Invite))
            {
                links.Append(GetText(Localization.HelpInviteMe, Credentials.Invite)).Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Website))
            {
                links.Append(GetText(Localization.HelpWebsite, Credentials.Website)).Append("\n");
            }

            if (links.Length > 0)
            {
                links.Append(delimiter);
            }
            if (!string.IsNullOrEmpty(Credentials.Patreon))
            {
                links.Append(GetText(Localization.HelpDonate, Credentials.Patreon)).Append("\n");
            }

            embed.AddField(GetText(Localization.HelpLinks), links.ToString());
            await ReplyAsync(embed);
        }
        public async Task Queens()
        {
            var lenght = Math.Min(Data.ImposterQueens.Count, 25);
            var order  = Data.ImposterQueens.Take(lenght).OrderByDescending(x => x.count);
            var sb     = new StringBuilder();
            var eb     = new LocalEmbedBuilder().WithTitle($"Top {lenght} Queens");

            foreach (var(id, count) in order)
            {
                var user = Context.Guild.GetMember(id);
                sb.AppendLine($"{user.DisplayName}  {(Data.WhitelistedIds.Any(x => x == user.Id) ? $"has betrayed trust: {count} times" : "user is not whitelisted as imposter")}");
            }
            eb.WithDescription(sb.ToString());
            await ReplyAsync("", eb, LocalMentions.None);
        }
        public static bool TryParseEmbed(string json, out LocalEmbedBuilder embed)
        {
            embed = new LocalEmbedBuilder();
            try
            {
                var embedDeserialized = JsonConvert.DeserializeObject <JsonEmbed>(json);

                var author      = embedDeserialized.Author;
                var title       = embedDeserialized.Title;
                var description = embedDeserialized.Description;

                var colorString = embedDeserialized.Color;
                var thumbnail   = embedDeserialized.Thumbnail;
                var image       = embedDeserialized.Image;
                var fields      = embedDeserialized.Fields;
                var footer      = embedDeserialized.Footer;
                var timestamp   = embedDeserialized.Timestamp;

                if (author != null)
                {
                    embed.WithAuthor(author);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    embed.WithTitle(title);
                }

                if (!string.IsNullOrEmpty(description))
                {
                    embed.WithDescription(description);
                }

                if (!string.IsNullOrEmpty(colorString))
                {
                    embed.WithColor(HexToInt(colorString) ?? 0xFFFFFF);
                }

                if (!string.IsNullOrEmpty(thumbnail))
                {
                    embed.WithThumbnailUrl(thumbnail);
                }
                if (!string.IsNullOrEmpty(image))
                {
                    embed.WithImageUrl(image);
                }

                if (fields != null)
                {
                    foreach (var field in fields)
                    {
                        var fieldName   = field.Name;
                        var fieldValue  = field.Value;
                        var fieldInline = field.IsInline;

                        if (!string.IsNullOrEmpty(fieldName) && !string.IsNullOrEmpty(fieldValue))
                        {
                            embed.AddField(fieldName, fieldValue, fieldInline);
                        }
                    }
                }

                if (footer != null)
                {
                    embed.WithFooter(footer);
                }

                if (timestamp.HasValue)
                {
                    embed.WithTimestamp(timestamp.Value);
                }
                else if (embedDeserialized.WithCurrentTimestamp)
                {
                    embed.WithCurrentTimestamp();
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        private async Task SendTargetEmbedAsync(Punishment punishment, IUser target, Punishment additionalPunishment, LocalizedLanguage language)
        {
            var typeName = punishment.GetType().Name.ToLower();
            var builder  = new LocalEmbedBuilder().WithErrorColor()
                           .WithTitle(_localization.Localize(language, $"punishment_{typeName}") +
                                      $" - {_localization.Localize(language, "punishment_case", punishment.Id)}")
                           .AddField(_localization.Localize(language, "title_reason"),
                                     punishment.Reason ?? _localization.Localize(language, "punishment_noreason"))
                           .WithTimestamp(punishment.CreatedAt);

            if (!(additionalPunishment is null))
            {
                builder.AddField(FormatAdditionalPunishment(additionalPunishment, language));
            }

            if (punishment is Warning)
            {
                using var ctx = new AdminDatabaseContext(_provider);

                var warningCount = await ctx.Punishments.OfType <Warning>().CountAsync(x =>
                                                                                       x.TargetId == target.Id && x.GuildId == punishment.GuildId && !x.RevokedAt.HasValue);

                builder.WithDescription(_localization.Localize(language, "punishment_warning_description",
                                                               Markdown.Bold(_client.GetGuild(punishment.GuildId).Name.Sanitize()),
                                                               Markdown.Bold(warningCount.ToOrdinalWords(language.Culture))));
            }
            else
            {
                builder.WithDescription(_localization.Localize(language, $"punishment_{typeName}_description",
                                                               _client.GetGuild(punishment.GuildId).Name));
            }

            if (punishment is RevocablePunishment revocable)
            {
                var field = new LocalEmbedFieldBuilder()
                            .WithName(_localization.Localize(language, "punishment_appeal"));

                switch (revocable)
                {
                case Ban ban:
                    field.WithValue(!ban.Duration.HasValue || ban.Duration.Value > TimeSpan.FromDays(1)
                            ? GetAppealInstructions()
                            : _localization.Localize(language, "punishment_tooshort",
                                                     ban.Duration.Value.Humanize(minUnit: TimeUnit.Minute, culture: language.Culture)));
                    break;

                case Mute mute:
                    field.WithValue(!mute.Duration.HasValue || mute.Duration.Value > TimeSpan.FromDays(1)
                            ? GetAppealInstructions()
                            : _localization.Localize(language, "punishment_tooshort",
                                                     mute.Duration.Value.Humanize(minUnit: TimeUnit.Minute, culture: language.Culture)));
                    break;

                default:
                    field = null;
                    break;
                }

                if (!(field is null))
                {
                    builder.AddField(field);
                }

                string GetAppealInstructions()
                {
                    return(_localization.Localize(language, "punishment_appeal_instructions",
                                                  Markdown.Code(punishment.Id.ToString()),
                                                  Markdown.Code($"{_config.DefaultPrefix}appeal {punishment.Id} [{_localization.Localize(language, "title_reason").ToLower()}]")));
                }
            }

            if (punishment is Mute channelMute && channelMute.ChannelId.HasValue)
            {
                builder.AddField(_localization.Localize(language, "punishment_mute_channel"),
                                 _client.GetGuild(punishment.GuildId).GetTextChannel(channelMute.ChannelId.Value).Mention);
            }

            if (punishment.Format != ImageFormat.Default)
            {
                builder.WithImageUrl($"attachment://attachment.{punishment.Format.ToString().ToLower()}");
                _ = target.SendMessageAsync(new LocalAttachment(punishment.Image,
                                                                $"attachment.{punishment.Format.ToString().ToLower()}"), embed: builder.Build());

                return;
            }

            _ = target.SendMessageAsync(embed: builder.Build());
        }
Exemple #10
0
        private async Task HandleReceivedMessageAsync(CachedUserMessage message)
        {
            if (message.Author.IsBot)
            {
                return;
            }

            if (!(message.Channel is CachedTextChannel textChannel) ||
                !textChannel.Guild.CurrentMember.GetPermissionsFor(textChannel).Has(Permission.SendMessages))
            {
                return;
            }
            if (CommandUtilities.HasAnyPrefix(message.Content, Prefixes, StringComparison.CurrentCulture, out var prefix, out var output) ||
                CommandUtilities.HasPrefix(message.Content, $"<@{Client.CurrentUser.Id}>", StringComparison.Ordinal, out output) ||
                CommandUtilities.HasPrefix(message.Content, $"<@!{Client.CurrentUser.Id}>", StringComparison.Ordinal, out output))
            {
                if (string.IsNullOrWhiteSpace(output))
                {
                    return;
                }

                try
                {
                    if (prefix is null)
                    {
                        prefix = Client.CurrentUser.Mention;
                    }
                    var ctx = MummyContext.Create(Client, message, Services, prefix);


                    ActiveTimings[ctx.UserId] = Stopwatch.StartNew();
                    var r = await Commands.ExecuteAsync(output, ctx);

                    ActiveTimings[ctx.UserId].Stop();
                    ActiveTimings.Remove(ctx.UserId, out var st);
                    if (r.IsSuccessful)
                    {
                        LogService.LogInformation($"command: {ctx.Command.Name} has successful finished execution in {st.ElapsedMilliseconds}ms.", LogSource.MessagesService, ctx.GuildId);
                    }
                    else
                    {
                        switch (r)
                        {
                        case ExecutionFailedResult executionfailed:
                        {
                            LogService.LogError(executionfailed.ToString(), LogSource.MessagesService, ctx.GuildId, executionfailed.Exception);

                            break;
                        }

                        case ArgumentParseFailedResult parsefailed:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithTitle("ArmgumentParseFailure");
                            eb.AddField(parsefailed.Reason, parsefailed.RawArguments);
                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case ArgumentParserResult parseresult:
                        {
                            LogService.LogCritical("dunno argumentparse", LogSource.MessagesService, ctx.GuildId);
                            await ctx.Channel.SendMessageAsync("a error has occoured and not been handled this error will be resolved shortly. (hopefully)");

                            break;
                        }

                        case ChecksFailedResult checksfailed:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithTitle($"{checksfailed.FailedChecks.Count} checks have failed");
                            foreach (var(Check, Result) in checksfailed.FailedChecks)
                            {
                                eb.AddField((Check as MummyCheckBase).Name, Result.Reason, true);
                            }
                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case CommandDisabledResult disabled:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            await ctx.Channel.SendMessageAsync();

                            eb.WithTitle($"{disabled.Command} is currently diabled");

                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case CommandNotFoundResult notfound:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithTitle($"command with name {notfound.Reason}");
                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case CommandOnCooldownResult oncooldown:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithTitle($"{oncooldown.Command.Name} is currently on cooldown");
                            foreach (var(cooldown, retryafter) in oncooldown.Cooldowns)
                            {
                                int index     = cooldown.ToString().LastIndexOf('.');
                                var bucketype = (CooldownBucketType)cooldown.BucketType;
                                eb.AddField(cooldown.ToString().Substring(index + 1), $"is only allowed to be run {cooldown.Amount} per {cooldown.Per.Humanize()} and it forced per {bucketype}, currently locked for {retryafter.TotalMinutes} Minutes", true);
                            }
                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case OverloadsFailedResult overloadsFailed:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithDescription(overloadsFailed.Reason);
                            foreach (var(command, overloadResult) in overloadsFailed.FailedOverloads)
                            {
                                eb.AddField($"{command.Name} {string.Join(' ', command.Parameters.Select(x => x.Name))}", overloadResult.Reason);
                            }

                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }

                        case ParameterChecksFailedResult paramcheckfailed:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.WithTitle($"checks on {paramcheckfailed.Parameter} have failed with provided argument: {paramcheckfailed.Argument}");
                            foreach (var(Check, Result) in paramcheckfailed.FailedChecks)
                            {
                                var index = Check.ToString().LastIndexOf('.');
                                var name  = Check.ToString().Substring(index + 1);
                                eb.AddField(name, Result.Reason);
                            }
                            break;
                        }

                        case TypeParseFailedResult typeParseFailed:
                        {
                            var eb = new LocalEmbedBuilder();
                            eb.WithAuthor(ctx.User);
                            eb.AddField(typeParseFailed.Parameter.Name, typeParseFailed.Reason);
                            await ctx.Channel.SendMessageAsync(embed : eb.Build());

                            break;
                        }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogService.LogError("Issue with message service", LogSource.MessagesService, exception: ex);
                }
            }
        }
        public async Task Eval([Remainder] string code)
        {
            var builder = new LocalEmbedBuilder
            {
                Title       = "Evaluating Code...",
                Color       = Color.DarkRed,
                Description = "Waiting for completion...",
                Author      = new LocalEmbedAuthorBuilder
                {
                    IconUrl = Context.User.GetAvatarUrl(),
                    Name    = Context.User.DisplayName
                },
                Timestamp    = DateTimeOffset.UtcNow,
                ThumbnailUrl = Context.Guild.CurrentMember.GetAvatarUrl()
            };
            var msg = await ReplyAsync(embed : builder);

            var sw     = Stopwatch.StartNew();
            var script = EvalService.Build(code);

            string snippet = string.Join(Environment.NewLine, script.Code.Split(Environment.NewLine.ToCharArray()).Where(line => !line.StartsWith("using")));

            var diagnostics     = script.Compile();
            var compilationTime = sw.ElapsedMilliseconds;

            if (diagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
            {
                builder.WithDescription($"Compilation finished in: {compilationTime}ms");
                builder.WithColor(Color.Red);
                builder.WithTitle("Failed Evaluation");

                builder.AddField("Code", $"```cs{Environment.NewLine}{snippet}```");
                builder.AddField("Compilation Errors", string.Join('\n', diagnostics.Select(x => $"{x}")));

                await msg.ModifyAsync(x => x.Embed = builder.Build());

                return;
            }
            sw.Restart();

            var context = new RoslynContext(Context, Services);

            try
            {
                var result = await script.RunAsync(context);

                sw.Stop();
                builder.WithColor(Color.Green);

                builder.WithDescription($"Code compiled in {compilationTime}ms and ran in {sw.ElapsedMilliseconds}ms");
                builder.WithTitle("Code Evaluated");
                builder.AddField("Code", $"```cs{Environment.NewLine}{snippet}```");

                if (!(result.ReturnValue is null))
                {
                    var sb     = new StringBuilder();
                    var type   = result.ReturnValue.GetType();
                    var rValue = result.ReturnValue;

                    switch (rValue)
                    {
                    case Color col:
                        builder.WithColor(col);
                        builder.AddField("Colour", $"{col.RawValue}");
                        break;

                    case string str:
                        builder.AddField($"{type}", $"\"{str}\"");
                        break;

                    case IEnumerable enumerable:

                        var list     = enumerable.Cast <object>().ToList();
                        var enumType = enumerable.GetType();

                        if (list.Count > 25)
                        {
                            builder.AddField($"{enumType}", $"Enumerable has more than 10 elements ({list.Count})");
                            break;
                        }

                        if (list.Count > 0)
                        {
                            sb.AppendLine("```css");

                            foreach (var element in list)
                            {
                                sb.Append('[').Append(element).AppendLine("]");
                            }

                            sb.AppendLine("```");
                        }
                        else
                        {
                            sb.AppendLine("Collection is empty");
                        }

                        builder.AddField($"{enumType}", sb.ToString());

                        break;

                    case Enum @enum:

                        builder.AddField($"{@enum.GetType()}", $"```\n{@enum.Humanize()}\n```");

                        break;

                    default:

                        var messages = rValue.Inspect();

                        if (type.IsValueType && messages.Count == 0)
                        {
                            builder.AddField($"{type}", rValue);
                        }

                        foreach (var message in messages)
                        {
                            await ReplyAsync($"```css\n{message}\n```");
                        }

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                sw.Stop();


                builder.WithDescription($"Code evaluated in {sw.ElapsedMilliseconds}ms but there was a issue tho");
                builder.WithColor(Color.Red);
                builder.WithTitle("Failed Evaluation");
                builder.AddField("Code", $"```cs{Environment.NewLine}{snippet}```");

                var str = ex.ToString();

                builder.AddField("Exception", Format.Sanitize(str.Length >= 1000 ? str.Substring(0, 1000) : str));
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            await msg.ModifyAsync(x => x.Embed = builder.Build());
        }
 public LocalizedEmbedBuilder WithDescription(string description)
 {
     _builder.WithDescription(description);
     return(this);
 }
Exemple #13
0
        public async Task HelpAsync()
        {
            var options = PaginatedAppearanceOptions.Default;
            var msg     = new PaginatedMessage {
                Options = options
            };
            var infoemb = new LocalEmbedBuilder();

            infoemb.AddField("optional", $"*value*", true);
            infoemb.AddField("remainder", "__value__", true);
            infoemb.AddField("required", "**value**", true);
            infoemb.WithDescription("for example: !command __*cookies this can contain spaces*__ this  means the command take a optional remainder");

            msg.Pages.Add(infoemb);

            foreach (var module in Commands.GetAllModules())
            {
                try
                {
                    var modulecheck = await module.RunChecksAsync(Context);

                    if (modulecheck.IsSuccessful)
                    {
                        if (module.Commands.Count == 0)
                        {
                            continue; //skip module if commands are 0
                        }
                        if (module.Parent != null)
                        {
                            continue;
                        }

                        var emb = new LocalEmbedBuilder();
                        emb.WithTitle(module.Name);
                        emb.WithAuthor(Context.User.DisplayName, Context.User.GetAvatarUrl());
                        var sb       = new StringBuilder();
                        var commands = CommandUtilities.EnumerateAllCommands(module);
                        foreach (var command in commands)
                        {
                            var checks = await command.RunChecksAsync(Context);

                            if (checks.IsSuccessful)
                            {
                                sb.Append(Context.PrefixUsed).Append(command.Name).Append(" ");
                                foreach (var parameter in command.Parameters)
                                {
                                    if (parameter.IsOptional && parameter.IsRemainder)//optional remiander
                                    {
                                        sb.Append($"__*{parameter.Name}*__ ");
                                    }
                                    else if (parameter.IsOptional && !parameter.IsRemainder)//optional
                                    {
                                        sb.Append($"*{parameter.Name}* ");
                                    }
                                    else if (!parameter.IsOptional && parameter.IsRemainder) //required remainder
                                    {
                                        sb.Append($"__**{parameter.Name}**__ ");
                                    }
                                    else if (!parameter.IsOptional && !parameter.IsRemainder)//required
                                    {
                                        sb.Append($"**{parameter.Name}** ");
                                    }
                                }
                                sb.AppendLine();
                            }
                        }
                        emb.WithDescription(sb.ToString());

                        msg.Pages.Add(emb);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            await new PaginatedMessageCallback(Iservice, Context, msg, new EnsureReactionFromUser(Context.User)).DisplayAsync();
        }
        public async Task HelpAsync(string alias1, string?alias2 = null)
        {
            var module  = GetModuleByAlias(alias1);
            var command = GetCommand(module, module is null ? alias1 : alias2);

            if (command is null)
            {
                await ReplyErrorAsync(Localization.HelpCommandNotFound, Context.Prefix);

                return;
            }

            var moduleAlias = module != null ? $"{module.Aliases[0]} " : string.Empty;
            var title       = string.Join(" / ", command.Aliases.Select(a => $"{Context.Prefix}{moduleAlias}{a}"));

            if (string.IsNullOrEmpty(title))
            {
                title = $"{Context.Prefix}{moduleAlias}";
            }

            var embed = new LocalEmbedBuilder
            {
                Color = RiasUtilities.ConfirmColor,
                Title = title
            };

            var moduleName = command.Module.Name;

            if (command.Module.Parent != null)
            {
                moduleName = $"{command.Module.Parent.Name} -> {moduleName}";
            }

            var description = new StringBuilder(command.Description)
                              .Append($"\n\n**{GetText(Localization.HelpModule)}**\n{moduleName}")
                              .Replace("[prefix]", Context.Prefix)
                              .Replace("[currency]", Credentials.Currency);

            embed.WithDescription(description.ToString());

            foreach (var attribute in command.Checks)
            {
                switch (attribute)
                {
                case UserPermissionAttribute userPermissionAttribute:
                    var userPermissions = userPermissionAttribute.GuildPermissions
                                          .GetValueOrDefault()
                                          .ToString()
                                          .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                          .Select(x => x.Humanize(LetterCasing.Title))
                                          .ToArray();
                    embed.AddField(GetText(Localization.HelpRequiresUserPermission), string.Join("\n", userPermissions), true);
                    break;

                case BotPermissionAttribute botPermissionAttribute:
                    var botPermissions = botPermissionAttribute.GuildPermissions
                                         .GetValueOrDefault()
                                         .ToString()
                                         .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                         .Select(x => x.Humanize(LetterCasing.Title))
                                         .ToArray();
                    embed.AddField(GetText(Localization.HelpRequiresBotPermission), string.Join("\n", botPermissions), true);
                    break;

                case OwnerOnlyAttribute _:
                    embed.AddField(GetText(Localization.HelpRequiresOwner), GetText(Localization.CommonYes), true);
                    break;
                }
            }

            var commandCooldown = command.Cooldowns.FirstOrDefault();

            if (commandCooldown != null)
            {
                var locale = Localization.GetGuildLocale(Context.Guild !.Id);
                embed.AddField(GetText(Localization.CommonCooldown),
                               $"{GetText(Localization.CommonAmount)}: **{commandCooldown.Amount}**\n" +
                               $"{GetText(Localization.CommonPeriod)}: **{commandCooldown.Per.Humanize(culture: new CultureInfo(locale))}**\n" +
                               $"{GetText(Localization.CommonPer)}: **{GetText(Localization.CommonCooldownBucketType(commandCooldown.BucketType.Humanize(LetterCasing.LowerCase).Underscore()))}**",
                               true);
            }

            embed.AddField(GetText(Localization.CommonExample), string.Format(command.Remarks, Context.Prefix));
            embed.WithCurrentTimestamp();

            await ReplyAsync(embed);
        }