Example #1
0
        private static Embed GetAboutEmbed()
        {
            var eb = new CustomEmbedBuilder();

            eb.WithThumbnailUrl("https://cdn.discordapp.com/avatars/669798825765896212/572b97a2e8c1dc33265ac51679303c41.png?size=256");
            eb.WithTitle("About");
            eb.AddField("Author", "This bot was created by Et3rnos#6556");
            eb.AddField("Support", "If you want to support me you can visit my Patreon:\n<https://www.patreon.com/et3rnos>");
            return(eb.Build());
        }
Example #2
0
        private static async Task <Embed> GetStatsEmbedAsync(DiscordSocketClient client, DatabaseContext dbContext, IConfigurationRoot configuration, IUser user, User player)
        {
            bool isTeam         = player.Team != null;
            bool dynamicScoring = configuration.GetValue <bool>("DynamicScoring");

            SharedStatsManager.Stats stats;
            if (isTeam)
            {
                stats = await SharedStatsManager.GetTeamStats(dbContext, player.Team, dynamicScoring);
            }
            else
            {
                stats = await SharedStatsManager.GetStats(dbContext, player, dynamicScoring);
            }

            var solvedChallengesTitles   = stats.SolvedChallenges.Select(x => x.Challenge.Title).ToList();
            var unsolvedChallengesTitles = stats.UnsolvedChallenges.Select(x => x.Challenge.Title).ToList();

            var eb = new CustomEmbedBuilder();

            if (isTeam)
            {
                eb.WithTitle($"Stats for {player.Team.Name} (team)");
                eb.AddField("Score", $"{stats.Score} ({stats.Position}/{stats.PlayersCount})");
            }
            else
            {
                eb.WithTitle($"Stats for {user.Username}");
                eb.WithThumbnailUrl(user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl());
                eb.AddField("Score", $"{stats.Score} ({stats.Position}/{stats.PlayersCount})");
            }

            if (solvedChallengesTitles.Count > 0)
            {
                eb.AddField("Solved Challenges", string.Join('\n', solvedChallengesTitles), true);
            }
            if (unsolvedChallengesTitles.Count > 0)
            {
                eb.AddField("Unsolved Challenges", string.Join('\n', unsolvedChallengesTitles), true);
            }

            return(eb.Build());
        }