Exemplo n.º 1
0
        private async Task MessageDeletedAsync(Cacheable <IMessage, ulong> cache, ISocketMessageChannel channel)
        {
            var guild = await _database.Guilds.AsNoTracking().FirstAsync(x => x.GuildId == (channel as SocketGuildChannel).Guild.Id);

            if (!guild.EnableDeletionLog)
            {
                return;
            }

            var message = cache.Value ?? await cache.GetOrDownloadAsync();

            if ((string.IsNullOrWhiteSpace(message.Content) && message.Attachments.Count is 0) || message.Author.IsBot)
            {
                return;
            }

            if (guild.MessageLogChannel is 0)
            {
                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Deleted)
                        .WithAuthor(message.Author)
                        .WithThumbnailUrl((message.Author as SocketUser)?.GetAvatar())
                        .WithTitle("Message Deleted")
                        .AddField("**Channel**:", "#" + message.Channel.Name)
                        .AddField("**Content**:", message.Attachments.FirstOrDefault()?.Url ?? message.Content)
                        .WithCurrentTimestamp()
                        .Build();

            var socketGuild = (message.Author as SocketGuildUser)?.Guild;
            var logChannel  = socketGuild.GetTextChannel(guild.MessageLogChannel);
            await logChannel.SendMessageAsync(embed : embed);
        }
Exemplo n.º 2
0
        public async Task KickAsync(
            [Name("User")]
            [Description("The user to kick, can either be @user, user id, or user/nick name (wrapped in quotes if it contains a space)")]
            SocketGuildUser user,
            [Name("Reason")]
            [Description("Reason for the kick")]
            [Remainder] string reason = null)
        {
            if (Context.Guild.HierarchyCheck(user))
            {
                await ReplyAsync(EmoteHelper.Cross + " Oops, clumsy me! `" + user + "` is higher than I.");

                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithAuthor(Context.User)
                        .WithTitle("Mod Action")
                        .WithDescription("You were kicked in the " + Context.Guild.Name + " guild.")
                        .WithThumbnailUrl(Context.User.GetAvatar())
                        .AddField("Reason", reason)
                        .Build();

            await user.TrySendDirectMessageAsync(embed : embed);

            await user.KickAsync(reason);

            await LogCaseAsync(user, CaseType.Kick, reason);

            await ReplyWithEmoteAsync(EmoteHelper.OkHand);
        }
Exemplo n.º 3
0
        public async Task BanAsync(
            [Name("User")]
            [Description("The user to ban, can either be @user, user id, or user/nick name (wrapped in quotes if it contains a space)")]
            SocketGuildUser user,
            [Name("Reason")]
            [Description("Reason for the ban")]
            [Remainder] string reason = null)
        {
            if (Context.Guild.HierarchyCheck(user))
            {
                await ReplyAsync(EmoteHelper.Cross + " Oops, clumsy me! *`" + user + "` is higher than I.*");

                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithAuthor(Context.User)
                        .WithTitle("Mod Action")
                        .WithDescription("You were banned in the " + Context.Guild.Name + " guild.")
                        .WithThumbnailUrl(Context.User.GetAvatar())
                        .AddField("Reason", reason)
                        .Build();

            await user.TrySendDirectMessageAsync(embed : embed);

            await Context.Guild.AddBanAsync(user, 7, reason);

            await LogCaseAsync(user, CaseType.Ban, reason);

            await ReplyAsync("You are remembered only for the mess you leave behind. *`" + user + "` was banned.* " + EmoteHelper.Hammer);
        }
Exemplo n.º 4
0
        public async Task SettingsAsync()
        {
            var guild = await Database.Guilds.AsNoTracking()
                        .Include(x => x.Tags)
                        .Include(x => x.CurrencyItems)
                        .Include(x => x.Shops)
                        .Include(x => x.Streams)
                        .Include(x => x.Leaderboards)
                        .Include(x => x.RssFeeds)
                        .Include(x => x.Cases)
                        .FirstAsync(x => x.GuildId == Context.Guild.Id);

            var embed = EmbedHelper.Embed(EmbedHelper.Info)
                        .WithTitle(Context.Guild.Name + " Settings")
                        .WithDescription("Guild settings and data for the Administrators")
                        .WithCurrentTimestamp()
                        .AddField("General Information",
                                  "```"
                                  + "Prefix                : " + (await Database.BotConfigs.AsNoTracking().FirstAsync()).Prefix + "\n"
                                  + "Bot Change channel    : " + Context.Guild.GetChannelName(guild.BotChangeChannel) + "\n"
                                  + "Case Log channel      : " + Context.Guild.GetChannelName(guild.CaseLogChannel) + "\n"
                                  + "Message Log channel   : " + Context.Guild.GetChannelName(guild.MessageLogChannel) + "\n"
                                  + "Report channel        : " + Context.Guild.GetChannelName(guild.ReportLogChannel) + "\n"
                                  + "Rules channel         : " + Context.Guild.GetChannelName(guild.RulesChannel) + "\n"
                                  + "Announcement role     : " + Context.Guild.GetRoleName(guild.AnnouncementRole) + "\n"
                                  + "Lottery role          : " + Context.Guild.GetRoleName(guild.LotteryRole) + "\n"
                                  + "Mute role             : " + Context.Guild.GetRoleName(guild.MuteRole) + "\n"
                                  + "Playstation role      : " + Context.Guild.GetRoleName(guild.PlaystationRole) + "\n"
                                  + "Xbox role             : " + Context.Guild.GetRoleName(guild.XboxRole) + "\n"
                                  + "```")
                        .AddField("Mod Information",
                                  "```"
                                  + "Log Deleted Messages    : " + (guild.EnableDeletionLog ? "Enabled" : "Disabled") + "\n"
                                  + "Profanity Check         : " + (guild.EnableAntiProfanity ? "Enabled" : "Disabled") + "\n"
                                  + "Rss Feed                : " + (guild.EnableRssFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Mixer                   : " + (guild.EnableMixerFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Twitch                  : " + (guild.EnableTwitchFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Leaderboard             : " + (guild.EnableLeaderboardFeed ? "Enabled" : "Disabled") + "\n"
                                  + "Rss Feeds               : " + guild.RssFeeds.Count + "\n"
                                  + "Mixer Streams           : " + guild.Streams.Count(x => x.StreamType is StreamType.Mixer) + "\n"
                                  + "Twitch Stream           : " + guild.Streams.Count(x => x.StreamType is StreamType.Twitch) + "\n"
                                  + "Leaderboard Variants    : " + guild.Leaderboards.Count + "\n"
                                  + "Max Warnings            : " + guild.MaxWarnings + "\n"
                                  + "```")
                        .AddField("Guild Statistics",
                                  "```"
                                  + "Users Banned           : " + guild.Cases.Count(x => x.CaseType is CaseType.Ban) + "\n"
                                  + "Users Soft Banned      : " + guild.Cases.Count(x => x.CaseType is CaseType.Softban) + "\n"
                                  + "Users Kicked           : " + guild.Cases.Count(x => x.CaseType is CaseType.Kick) + "\n"
                                  + "Users Warned           : " + guild.Cases.Count(x => x.CaseType is CaseType.Warning) + "\n"
                                  + "Users Muted            : " + guild.Cases.Count(x => x.CaseType is CaseType.Mute) + "\n"
                                  + "Auto Mutes             : " + guild.Cases.Count(x => x.CaseType is CaseType.AutoMute) + "\n"
                                  + "Total Currency Items   : " + guild.CurrencyItems.Count + "\n"
                                  + "Total Shop Items       : " + guild.Shops.Count + "\n"
                                  + "Total Tags             : " + guild.Tags.Count + "\n"
                                  + "Total Mod Cases        : " + guild.Cases.Count + "\n"
                                  + "```");

            await ReplyAsync(embed : embed.Build());
        }
Exemplo n.º 5
0
 public Task Lab() => ReplyAsync(embed: EmbedHelper.Embed(EmbedHelper.Info)
                                 .WithTitle("Please turn off any Ad Blockers you have to help the team keep doing Izaros work.")
                                 .WithDescription("[Homepage](https://www.poelab.com/) - [Support](https://www.poelab.com/support/)")
                                 .AddField("Labrynth Info", "[Guide](https://www.poelab.com/new-to-labyrinth/) - [Enchantments](https://www.poelab.com/all-enchantments/)"
                                           + " - [Darkshrines](https://www.poelab.com/hidden-darkshrines/) - [Izaro's Phases](https://www.poelab.com/izaro-phases/) - [Izaro's Attacks](https://www.poelab.com/izaro-weapon-and-attacks/)"
                                           + " - [Traps](https://www.poelab.com/traps_and_trials/) - [Doors & Keys](https://www.poelab.com/doors-and-keys/) - [Puzzles](https://www.poelab.com/gauntlets-puzzles/)"
                                           + " - [Lore](https://www.poelab.com/lore/) - [Tips](https://www.poelab.com/labyrinth-tips/) - [Puzzle Solutions](https://www.poelab.com/puzzle-solutions/)"
                                           + " - [Trial Locations](https://www.poelab.com/trial-locations/) - [Trial Tracker](https://www.poelab.com/trial-tracker/) - [What makes a Good Labyrinth?](https://www.poelab.com/what-makes-a-good-labyrinth/)")
                                 .AddField("Leveling Guides", "[Act 1](https://www.poelab.com/act-1-leveling-guide/) - [Act 2](https://www.poelab.com/act-2-leveling-guide/)"
                                           + " - [Act 3](https://www.poelab.com/act-3-leveling-guide/) - [Act 4](https://www.poelab.com/act-4-leveling-guide/) - [Act 5](https://www.poelab.com/act-5-leveling-guide/)"
                                           + " - [Act 6](https://www.poelab.com/act-6-leveling-guide/) - [Act 7](https://www.poelab.com/act7-leveling-guide/) - [Act 8](https://www.poelab.com/act-8-leveling-guide/)"
                                           + " - [Act 9](https://www.poelab.com/act-9-leveling-guide/) - [Act 10](https://www.poelab.com/act-10-leveling-guide/)")
                                 .AddField("League Cheat sheets", "[Azurite Mine Rooms](https://www.poelab.com/azurite-mine-legend-rooms/) - [Incursion Rooms](https://www.poelab.com/incursion-rooms/)")
                                 .AddField("League Mechanics", "[Incursion](https://www.poelab.com/incursion/)")
                                 .AddField("Endgame Goals", "[Crafting an Item](https://www.poelab.com/crafting-an-item/) - [Road to Uber Elder](https://www.poelab.com/road-to-uber-elder/)"
                                           + " - [Zana and the Map Device](https://www.poelab.com/zana-and-the-map-device/)")
                                 .AddField("Endgame Boss Guides", "[Ahuatotli](https://www.poelab.com/ahuatotli-the-blind/) - [Atziri](https://www.poelab.com/atziri-queen-of-the-vaal/)"
                                           + " - [Aul](https://www.poelab.com/aul-the-crystal-king/) - [Chimera](https://www.poelab.com/guardian-of-the-chimera/) - [Constrictor](https://www.poelab.com/the-constrictor/)"
                                           + " - [Elder](https://www.poelab.com/the-elder/) - [Enslaver](https://www.poelab.com/the-enslaver/) - [Eradicator](https://www.poelab.com/the-eradicator/)"
                                           + " - [Hydra](https://www.poelab.com/guardian-of-the-hydra/) - [Minotaur](https://www.poelab.com/guardian-of-the-minotaur/) - [Phoenix](https://www.poelab.com/guardian-of-the-phoenix/)"
                                           + " - [Purifier](https://www.poelab.com/the-purifier/) - [Shaper](https://www.poelab.com/the-shaper-master-of-the-void/) - [Uber Elder](https://www.poelab.com/the-uber-elder/)"
                                           + " - [Vessel of the Vaal](https://www.poelab.com/the-vessel-of-the-vaals/)")
                                 .AddField("Breach Boss Guides", "[Chayula](https://www.poelab.com/chayula-who-dreamt/) - [Esh](https://www.poelab.com/esh-forked-thought/)"
                                           + " - [Tul](https://www.poelab.com/tul-creeping-avalanche/) - [Uul-Netol](https://www.poelab.com/uul-netol-unburdened-flesh/) - [Xoph](https://www.poelab.com/xoph-dark-embers/)")
                                 .AddField("Misc", "[Defensive Layers](https://www.poelab.com/defensive-layers/) - [Mapping Etique](https://www.poelab.com/mapping-etiquette/)")
                                 .Build());
Exemplo n.º 6
0
        public async Task ModuleHelpAsync(
            [Name("Module Name")]
            [Description("Module to get commands in")]
            [Remainder] string moduleName)
        {
            var module = Commands.GetAllModules().FirstOrDefault(x => string.Equals(x.Name, moduleName + " Module", StringComparison.CurrentCultureIgnoreCase));

            if (!(module is null))
            {
                var config = await Database.BotConfigs.AsNoTracking().FirstAsync();

                var embed = EmbedHelper.Embed(EmbedHelper.Info)
                            .WithAuthor("Command List", Context.Client.CurrentUser.GetAvatar())
                            .WithTitle("For more information on a command do " + config.Prefix + "help command")
                            .WithFooter("Current Prefix: " + config.Prefix)
                            .WithCurrentTimestamp();

                var passed = true;
                foreach (var precondition in module.Checks)
                {
                    if (!(await precondition.CheckAsync(Context, Services)).IsSuccessful)
                    {
                        passed = false;
                        break;
                    }
                }

                if (passed)
                {
                    var commands = new List <string>();
                    foreach (var command in module.Commands)
                    {
                        if (command.Name != "Tag")
                        {
                            commands.Add("**" + command.Name + "**\n" + command.Description);
                        }
                    }

                    if (!module.Name.Contains("Base"))
                    {
                        embed.WithDescription("\u200b\n**" + module.Description + "**\n\u200b\n" + string.Join("\n\n", commands));
                    }
                }

                await ReplyAsync(embed : embed.Build());
            }
Exemplo n.º 7
0
        public async Task BugAsync(
            [Name("Bug")]
            [Description("The bug you are experiencing, please be as descriptive as possible")]
            [Remainder] string bug)
        {
            var config = await Database.BotConfigs.AsNoTracking().FirstAsync();

            var channel = Context.Client.GetChannel(config.SupportChannel) as SocketTextChannel;
            var embed   = EmbedHelper.Embed(EmbedHelper.Deleted)
                          .WithAuthor(Context.User.GetDisplayName(), Context.User.GetAvatar())
                          .WithTitle("Bug Report")
                          .WithDescription(bug)
                          .AddField("Info", "User: "******" *(" + Context.User.Username + "#" + Context.User.Discriminator + ")*\nGuild: " + Context.Guild.Name + " - "
                                    + "*" + Context.Guild.Id + "*")
                          .WithCurrentTimestamp()
                          .Build();
            await channel.SendMessageAsync(embed : embed);

            await ReplyWithEmoteAsync(EmoteHelper.OkHand);
        }
Exemplo n.º 8
0
        public async Task FeatureAsync(
            [Name("Feature")]
            [Description("The new feature you'd like to see")]
            [Remainder] string feature)
        {
            var config = await Database.BotConfigs.AsNoTracking().FirstAsync();

            var channel = Context.Client.GetChannel(config.SupportChannel) as SocketTextChannel;
            var embed   = EmbedHelper.Embed(EmbedHelper.Added)
                          .WithAuthor(Context.User.GetDisplayName(), Context.User.GetAvatar())
                          .WithTitle("Feature Request")
                          .WithDescription(feature)
                          .AddField("Info", "User: "******" *(" + Context.User.Username + "#" + Context.User.Discriminator + ")*\nGuild: " + Context.Guild.Name + " - "
                                    + "*" + Context.Guild.Id + "*")
                          .WithCurrentTimestamp()
                          .Build();
            await channel.SendMessageAsync(embed : embed);

            await ReplyWithEmoteAsync(EmoteHelper.OkHand);
        }
Exemplo n.º 9
0
        public async Task CaseReasonAsync(
            [Name("Number")]
            [Description("The case number to update a reason for")]
            int number,
            [Name("Reason")]
            [Description("The new reason for the case")]
            [Remainder] string reason)
        {
            var userCase = await Database.Cases.Include(x => x.Guild).FirstOrDefaultAsync(x => x.Number == number && x.Guild.GuildId == Context.Guild.Id);

            var user      = Context.Guild.GetUser(userCase.UserId);
            var moderator = Context.Guild.GetUser(userCase.ModeratorId);
            var channel   = Context.Guild.GetTextChannel(userCase.Guild.CaseLogChannel);

            userCase.Reason = reason;

            if (!(channel is null) && await channel.GetMessageAsync(userCase.MessageId) is IUserMessage message)
            {
                var cases = await Database.Cases.AsNoTracking().Include(x => x.Guild).Where(x => x.UserId == user.Id && x.Guild.GuildId == Context.Guild.Id).ToListAsync();

                var embed = EmbedHelper.Embed(EmbedHelper.Case)
                            .WithAuthor("Case Number: " + userCase.Number)
                            .WithTitle(userCase.CaseType.ToString())
                            .AddField("User", user.Mention + " `" + user + "` (" + user.Id + ")")
                            .AddField("History",
                                      "Cases: " + cases.Count() + "\n"
                                      + "Warnings: " + cases.Count(x => x.CaseType == CaseType.Warning) + "\n"
                                      + "Mutes: " + cases.Count(x => x.CaseType == CaseType.Mute) + "\n"
                                      + "Auto Mutes: " + cases.Count(x => x.CaseType == CaseType.AutoMute) + "\n")
                            .AddField("Reason", userCase.Reason)
                            .AddField("Moderator", $"{moderator}")
                            .WithCurrentTimestamp()
                            .Build();

                await message.ModifyAsync(x => x.Embed = embed);
            }

            await Database.SaveChangesAsync();

            await ReplyWithEmoteAsync(EmoteHelper.OkHand);
        }
Exemplo n.º 10
0
        public async Task HelpAsync(
            [Name("Command Name")]
            [Description("Command to get more info on")]
            [Remainder] string commandName)
        {
            var search = Commands.GetAllCommands().Where(x => string.Equals(x.Name, commandName, StringComparison.CurrentCultureIgnoreCase));

            if (search.Count() is 0)
            {
                await ReplyAsync(EmoteHelper.Cross + " No command found for `" + commandName + "`");

                return;
            }

            var command       = search.First();
            var commandParams = string.Empty;

            foreach (var param in command.Parameters)
            {
                commandParams += "*" + param.Name + "* - " + param.Description + "\n";
            }

            var commandInfo = new EmbedFieldBuilder
            {
                Name  = command.Name,
                Value = "**Aliases**: " + string.Join(", ", command.Aliases) + "\n"
                        + "**Description**: " + command.Description + "\n"
                        + "**Usage**: " + (await Database.BotConfigs.AsNoTracking().FirstAsync()).Prefix + (command.Attributes.FirstOrDefault(x => x is UsageAttribute) as UsageAttribute)?.ExampleUsage
                        + "\n" + (commandParams.Length > 0 ? "**Parameter(s)**: \n" + commandParams : "")
            };

            await ReplyAsync(embed : EmbedHelper.Embed(EmbedHelper.Info)
                             .WithAuthor(Context.User.GetDisplayName(), Context.User.GetAvatar())
                             .AddField(commandInfo)
                             .WithCurrentTimestamp()
                             .Build());
        }
Exemplo n.º 11
0
        public async Task InfoAsync(
            [Name("Tag Name")]
            [Description("Name of the tag. To specify more than one word, wrap your name with quotes \"like this\"")]
            [Remainder] string tagName)
        {
            var guild = await Database.Guilds.AsNoTracking().Include(x => x.Tags).FirstAsync(x => x.GuildId == Context.Guild.Id);

            if (!TryParseTag(tagName, guild, out var tag))
            {
                await SuggestTags(tagName, guild);

                return;
            }

            await ReplyAsync(embed : EmbedHelper.Embed(EmbedHelper.Info)
                             .WithAuthor("Tag Information", Context.Guild.GetUser(tag.UserId).GetAvatar())
                             .WithThumbnailUrl(Context.Guild.GetUser(tag.UserId).GetAvatar())
                             .AddField("Name", tag.Name, true)
                             .AddField("Owner", Context.Guild.GetUser(tag.UserId).GetDisplayName(), true)
                             .AddField("Uses", tag.Uses, true)
                             .AddField("Created On", tag.CreationDate, true)
                             .AddField("Content", tag.Content, true)
                             .Build());
        }
Exemplo n.º 12
0
        private async Task <List <Object> > BuildRssFeedAsync(RssFeed feed, List <RssItem> posts, SocketGuild socketGuild)
        {
            List <Object> messages = new List <Object>();

            foreach (var item in posts)
            {
                var embed = EmbedHelper.Embed(EmbedHelper.RSS);
                var sb    = new StringBuilder();

                string description = StripTagsCharArray(RoughStrip(HtmlEntity.DeEntitize(item.Description)));
                description = description.Length > 800 ? $"{description.Substring(0, 800)} [...]" : description;
                var feedUri = new Uri(feed.FeedUrl);

                switch (feedUri)
                {
                case Uri uri when feedUri.Host is "www.gggtracker.com":
                    sb.AppendLine("-----------------------------------------------------------")
                    .Append(":newspaper: ***").Append(CleanTitle(item.Title)).AppendLine("***\n")
                    .AppendLine(item.Link)
                    .Append("```").Append(description).AppendLine("```");
                    messages.Add(sb);
                    break;

                case Uri uri when feedUri.Host is "www.poelab.com":
                    sb.AppendLine("-----------------------------------------------------------")
                    .Append("***").Append(CleanTitle(item.Title)).AppendLine("***")
                    .AppendLine("*Please turn off any Ad Blockers you have to help the team keep doing Izaros work.*")
                    .AppendLine(item.Link);

                    string labDescription = "Lab notes not added.";

                    if (item.Comments > 0 && item.Title.Contains("Uber"))
                    {
                        var commentRSS = await GetRssAsync(item.CommentRss);

                        var comment = commentRSS.Data.Items.Find(x => x.Title is "By: SuitSizeSmall");
                        if (!(comment is null))
                        {
                            labDescription = comment.Description;
                        }
                    }

                    sb.Append("```").Append(labDescription).AppendLine("```");

                    messages.Add(sb);
                    break;

                case Uri uri when feedUri.Host is "www.pathofexile.com":
                    embed.WithTitle(CleanTitle(item.Title))
                    .WithDescription(description)
                    .WithUrl(item.Link)
                    .WithTimestamp(new DateTimeOffset(Convert.ToDateTime(item.PubDate).ToUniversalTime()));

                    string newsImage = await GetAnnouncementImageAsync(item.Link);

                    if (!string.IsNullOrWhiteSpace(newsImage))
                    {
                        embed.WithImageUrl(newsImage);
                    }

                    messages.Add(embed);
                    break;

                default:
                    sb.Append("***").Append(CleanTitle(item.Title)).AppendLine("***\n")
                    .AppendLine(item.Link)
                    .Append("```").Append(description).AppendLine("```");

                    messages.Add(sb);
                    break;
                }
            }

            //await _log.LogMessage(new LogMessage(LogSeverity.Error, "Rss", string.Empty, ex));
            return(messages);
        }
Exemplo n.º 13
0
        private Embed BuildTopClassEmbed(LeaderboardData data, string leaderboard)
        {
            var sb    = new StringBuilder();
            var embed = EmbedHelper.Embed(EmbedHelper.Leaderboard)
                        .WithTitle(WebUtility.UrlDecode(leaderboard).Replace("_", " ") + " Leaderboard")
                        .WithDescription("Retrieved " + data.AllRecords.Count.ToString("##,##0") + " records.")
                        .WithCurrentTimestamp()
                        .AddField("Top 10 Characters of each Class", "Rank is overall and not by Class.");

            var duelists = data.AllRecords.Where(x => x.Class is AscendancyClass.Duelist || x.Class is AscendancyClass.Slayer || x.Class is AscendancyClass.Gladiator ||
                                                 x.Class is AscendancyClass.Champion).ToList();
            var marauders = data.AllRecords.Where(x => x.Class is AscendancyClass.Marauder || x.Class is AscendancyClass.Juggernaut || x.Class is AscendancyClass.Chieftain ||
                                                  x.Class is AscendancyClass.Berserker).ToList();
            var rangers = data.AllRecords.Where(x => x.Class is AscendancyClass.Ranger || x.Class is AscendancyClass.Raider || x.Class is AscendancyClass.Deadeye ||
                                                x.Class is AscendancyClass.Pathfinder).ToList();
            var scions  = data.AllRecords.Where(x => x.Class is AscendancyClass.Scion || x.Class is AscendancyClass.Ascendant).ToList();
            var shadows = data.AllRecords.Where(x => x.Class is AscendancyClass.Shadow || x.Class is AscendancyClass.Saboteur || x.Class is AscendancyClass.Assassin ||
                                                x.Class is AscendancyClass.Trickster).ToList();
            var templars = data.AllRecords.Where(x => x.Class is AscendancyClass.Templar || x.Class is AscendancyClass.Inquisitor || x.Class is AscendancyClass.Hierophant ||
                                                 x.Class is AscendancyClass.Guardian).ToList();
            var witches = data.AllRecords.Where(x => x.Class is AscendancyClass.Witch || x.Class is AscendancyClass.Necromancer || x.Class is AscendancyClass.Occultist ||
                                                x.Class is AscendancyClass.Elementalist).ToList();

            if (duelists.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in duelists.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Duelists, Slayers, Champions, Gladiators", "```" + sb + "```");
            }

            if (marauders.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in marauders.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Marauders, Juggernauts, Chieftains, Berserkers", "```" + sb + "```");
            }

            if (rangers.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in rangers.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Rangers, Pathfinders, Raiders, Deadeyes", "```" + sb + "```");
            }

            if (scions.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in scions.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Scions, Ascendants", "```" + sb + "```");
            }

            if (shadows.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in shadows.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Shadows, Saboteurs, Assassins, Tricksters", "```" + sb + "```");
            }

            if (templars.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in templars.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Templars, Guardians, Inquisitors, Hierophants", "```" + sb + "```");
            }

            if (witches.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in witches.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Witches, Necromancers, Occultists, Elementalists", "```" + sb + "```");
            }

            return(embed.Build());
        }
Exemplo n.º 14
0
        private Embed BuildSecondTopAscendancyEmbed(LeaderboardData data)
        {
            var sb    = new StringBuilder();
            var embed = EmbedHelper.Embed(EmbedHelper.Leaderboard)
                        .WithTitle("Top 10 Characters of each Ascendancy")
                        .WithDescription("Rank is overall and not by Ascendancy.")
                        .WithCurrentTimestamp();

            if (data.Inquisitors.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Inquisitors.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Inquisitors", "```" + sb + "```");
            }

            if (data.Juggernauts.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Juggernauts.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Juggernauts", "```" + sb + "```");
            }

            if (data.Necromancers.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Necromancers.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Necromancers", "```" + sb + "```");
            }

            if (data.Occultists.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Occultists.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Occultists", "```" + sb + "```");
            }

            if (data.Pathfinders.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Pathfinders.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Pathfinders", "```" + sb + "```");
            }

            if (data.Raiders.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Raiders.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Raiders", "```" + sb + "```");
            }

            if (data.Saboteurs.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Saboteurs.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Saboteurs", "```" + sb + "```");
            }

            if (data.Slayers.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Slayers.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Slayers", "```" + sb + "```");
            }

            if (data.Tricksters.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Tricksters.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Tricksters", "```" + sb + "```");
            }
            return(embed.Build());
        }
Exemplo n.º 15
0
        private Embed BuildFirstTopAscendancyEmbed(LeaderboardData data)
        {
            var sb    = new StringBuilder();
            var embed = EmbedHelper.Embed(EmbedHelper.Leaderboard)
                        .WithTitle("Top 10 Characters of each Ascendancy")
                        .WithDescription("Rank is overall and not by Ascendancy.")
                        .WithCurrentTimestamp();

            if (data.Ascendants.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Ascendants.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Ascendants", "```" + sb + "```");
            }

            if (data.Assassins.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Assassins.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Assassins", "```" + sb + "```");
            }

            if (data.Berserkers.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Berserkers.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Berserkers", "```" + sb + "```");
            }

            if (data.Champions.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Champions.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Champions", "```" + sb + "```");
            }

            if (data.Chieftains.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Chieftains.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Chieftains", "```" + sb + "```");
            }

            if (data.Deadeyes.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Deadeyes.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Deadeyes", "```" + sb + "```");
            }

            if (data.Elementalists.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Elementalists.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Elementalists", "```" + sb + "```");
            }

            if (data.Gladiators.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Gladiators.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Gladiators", "```" + sb + "```");
            }

            if (data.Guardians.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Guardians.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Guardians", "```" + sb + "```");
            }

            if (data.Hierophants.Count > 0)
            {
                sb = new StringBuilder();
                foreach (var item in data.Hierophants.Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Hierophants", "```" + sb + "```");
            }

            return(embed.Build());
        }
Exemplo n.º 16
0
        private Embed BuildDiscordOnlyEmbed(LeaderboardData data, string leaderboard)
        {
            var sb    = new StringBuilder();
            var embed = EmbedHelper.Embed(EmbedHelper.Leaderboard)
                        .WithTitle("Discordians Only " + leaderboard.Replace("_", " ") + " Leaderboard")
                        .WithDescription("Retrieved " + data.Discordians.Count.ToString("##,##0") + " users with Discord in their name.")
                        .WithCurrentTimestamp()
                        .AddField("Top 10 Characters of each Class Ascendancy", "Rank is overall and not by Ascendancy.");

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Duelist || x.Class is AscendancyClass.Slayer || x.Class is AscendancyClass.Champion ||
                                     x.Class is AscendancyClass.Gladiator))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Duelist || x.Class is AscendancyClass.Slayer ||
                                                            x.Class is AscendancyClass.Champion || x.Class is AscendancyClass.Gladiator).Take(10))
                {
                    sb = FormatData(sb, item);
                }

                embed.AddField("Duelists, Slayers, Champions, Gladiators", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Marauder || x.Class is AscendancyClass.Juggernaut || x.Class is AscendancyClass.Chieftain ||
                                     x.Class is AscendancyClass.Berserker))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Marauder || x.Class is AscendancyClass.Juggernaut ||
                                                            x.Class is AscendancyClass.Chieftain || x.Class is AscendancyClass.Berserker).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Marauders, Juggernauts, Chieftains, Berserkers", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Ranger || x.Class is AscendancyClass.Pathfinder || x.Class is AscendancyClass.Deadeye ||
                                     x.Class is AscendancyClass.Raider))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Ranger || x.Class is AscendancyClass.Pathfinder ||
                                                            x.Class is AscendancyClass.Deadeye || x.Class is AscendancyClass.Raider).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Rangers, Pathfinders, Raiders, Deadeyes", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Scion || x.Class is AscendancyClass.Ascendant))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Scion || x.Class is AscendancyClass.Ascendant).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Scions, Ascendants", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Shadow || x.Class is AscendancyClass.Saboteur || x.Class is AscendancyClass.Assassin ||
                                     x.Class is AscendancyClass.Trickster))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Shadow || x.Class is AscendancyClass.Saboteur ||
                                                            x.Class is AscendancyClass.Assassin || x.Class is AscendancyClass.Trickster).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Shadows, Saboteurs, Assassins, Tricksters", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Templar || x.Class is AscendancyClass.Guardian || x.Class is AscendancyClass.Inquisitor ||
                                     x.Class is AscendancyClass.Hierophant))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Templar || x.Class is AscendancyClass.Guardian ||
                                                            x.Class is AscendancyClass.Inquisitor || x.Class is AscendancyClass.Hierophant).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Templars, Guardians, Inquisitors, Hierophants", "```" + sb + "```");
            }

            if (data.Discordians.Any(x => x.Class is AscendancyClass.Witch || x.Class is AscendancyClass.Necromancer || x.Class is AscendancyClass.Occultist ||
                                     x.Class is AscendancyClass.Elementalist))
            {
                sb = new StringBuilder();
                foreach (var item in data.Discordians.Where(x => x.Class is AscendancyClass.Witch || x.Class is AscendancyClass.Necromancer ||
                                                            x.Class is AscendancyClass.Occultist || x.Class is AscendancyClass.Elementalist).Take(10))
                {
                    sb = FormatData(sb, item);
                }
                embed.AddField("Witches, Necromancers, Occultists, Elementalists", "```" + sb + "```");
            }

            return(embed.Build());
        }
Exemplo n.º 17
0
        public async Task EvalAsync(
            [Name("Code")]
            [Description("The code you want to evaluate")]
            [Remainder] string script)
        {
            var props  = new EvaluationHelper(Context);
            var result = await Scripting.EvaluateScriptAsync(script, props);

            var    canUseEmbed = true;
            string stringRep;

            if (result.IsSuccess)
            {
                if (result.ReturnValue != null)
                {
                    var special = false;

                    switch (result.ReturnValue)
                    {
                    case string str:
                        stringRep = str;
                        break;

                    case IDictionary dictionary:
                        var asb = new StringBuilder();
                        asb.Append("Dictionary of type ``").Append(dictionary.GetType().Name).AppendLine("``");
                        foreach (var ent in dictionary.Keys)
                        {
                            asb.Append("- ``").Append(ent).Append("``: ``").Append(dictionary[ent]).AppendLine("``");
                        }

                        stringRep   = asb.ToString();
                        special     = true;
                        canUseEmbed = false;
                        break;

                    case IEnumerable enumerable:
                        var asb0 = new StringBuilder();
                        asb0.Append("Enumerable of type ``").Append(enumerable.GetType().Name).AppendLine("``");
                        foreach (var ent in enumerable)
                        {
                            asb0.Append("- ``").Append(ent).AppendLine("``");
                        }

                        stringRep   = asb0.ToString();
                        special     = true;
                        canUseEmbed = false;
                        break;

                    default:
                        stringRep = result.ReturnValue.ToString();
                        break;
                    }

                    if ((stringRep.StartsWith("```") && stringRep.EndsWith("```")) || special)
                    {
                        canUseEmbed = false;
                    }
                    else
                    {
                        stringRep = $"```cs\n{stringRep}```";
                    }
                }
                else
                {
                    stringRep = "No results returned.";
                }

                if (canUseEmbed)
                {
                    var footerString = $"{(result.CompilationTime != -1 ? $"Compilation time: {result.CompilationTime}ms" : "")} {(result.ExecutionTime != -1 ? $"| Execution time: {result.ExecutionTime}ms" : "")}";

                    await ReplyAsync(embed : EmbedHelper.Embed(EmbedHelper.Added)
                                     .WithTitle("Scripting Result")
                                     .WithDescription(result.ReturnValue != null ? "Type: `" + result.ReturnValue.GetType().Name + "`" : "")
                                     .AddField("Input", $"```cs\n{script}```")
                                     .AddField("Output", stringRep)
                                     .WithFooter(footerString, Context.Client.CurrentUser.GetAvatar())
                                     .Build());

                    return;
                }

                await ReplyAsync(stringRep);

                return;
            }

            var embed = EmbedHelper.Embed(EmbedHelper.Deleted)
                        .WithTitle("Scripting Result")
                        .WithDescription("Scripting failed during stage **" + FormatEnumMember(result.FailedStage) + "**");

            embed.AddField("Input", $"```cs\n{script}```");

            if (result.CompilationDiagnostics?.Count > 0)
            {
                var field = new EmbedFieldBuilder {
                    Name = "Compilation Errors"
                };
                var sb = new StringBuilder();
                foreach (var compilationDiagnostic in result.CompilationDiagnostics.OrderBy(a => a.Location.SourceSpan.Start))
                {
                    var start = compilationDiagnostic.Location.SourceSpan.Start;
                    var end   = compilationDiagnostic.Location.SourceSpan.End;

                    var bottomRow = script.Substring(start, end - start);

                    if (!string.IsNullOrEmpty(bottomRow))
                    {
                        sb.Append("`").Append(bottomRow).AppendLine("`");
                    }

                    sb.Append(" - ``").Append(compilationDiagnostic.Id).Append("`` (").Append(FormatDiagnosticLocation(compilationDiagnostic.Location)).Append("): **")
                    .Append(compilationDiagnostic.GetMessage()).AppendLine("**");
                    sb.AppendLine();
                }
                field.Value = sb.ToString();

                if (result.Exception != null)
                {
                    sb.AppendLine();
                }

                embed.AddField(field);
            }

            if (result.Exception != null)
            {
                embed.AddField("Exception", $"``{result.Exception.GetType().Name}``: ``{result.Exception.Message}``");
            }

            await ReplyAsync(embed : embed.Build());

            return;
        }