示例#1
0
        public DiscordEmbedBuilder CreateEmbed(MythicPlusStats stats)
        {
            var embed = new DiscordEmbedBuilder
            {
                Color     = new DiscordColor("#3AE6DB"),
                Title     = "Статистика Raider.IO",
                Timestamp = DateTime.UtcNow,
            };

            embed.WithFooter("(c) Raider.IO", "https://cdnassets.raider.io/images/brand/Mark_2ColorWhite.png");
            if (stats.ErrorMessage != null)
            {
                embed.AddField("Не получилось загрузить информацию", "Ответ сервера:\n" + stats.ErrorMessage +
                               "\n Проверьте верно ли вы ввели никнейм и сервер?\n Синтаксис:\n< -rio имя сервер >");
                return(embed);
            }
            embed.AddField("Имя", stats.Name, true);
            embed.AddField("Сервер", stats.Realm, true);
            embed.AddField("Специализация", stats.ActiveSpecName + " " + stats.Class, true);
            var scores = stats.MythicPlusScoresBySeasonList[0].Scores;

            embed.AddField("Рейтинг м+", "Урон: **" + scores.Dps + "**", true);
            embed.AddField("-", "Исцеление: **" + scores.Healer + "**", true);
            embed.AddField("-", "Танк: **" + scores.Tank + "**", true);
            embed.AddField("Лучшие пройденные", BestRuns(stats));

            return(embed);
        }
示例#2
0
        public string BestRuns(MythicPlusStats stats)
        {
            var collectInformation = new StringBuilder();

            foreach (var bestRun in stats.MythicPlusBestRuns)
            {
                var dungeonInRus = DungeonName.DungeonNameSqlConverter(bestRun.Dungeon);
                collectInformation.Append("**(" + bestRun.MythicLevel + "+" + bestRun.NumKeystoneUpgrades + ")** " +
                                          " *" + dungeonInRus + "*\n");
            }
            var result = collectInformation.ToString();

            if (string.IsNullOrEmpty(result))
            {
                result = "Персонаж не закрывал значимых подземелий с ключом";
            }
            return(result);
        }
示例#3
0
        public async Task <DiscordEmbedBuilder> MythicPlusRequest(string name, string[] serverNameInput)
        {
            string serverName;

            try
            { serverName = ServerName.RioServerNameConvert(serverNameInput); }
            catch (Exception e)
            {
                return(new DiscordEmbedBuilder
                {
                    Color = new DiscordColor("#3AE6DB"),
                    Title = "Ошибка запроса",
                    Description = e.Message,
                    Timestamp = DateTime.UtcNow,
                });
            }

            var encodedName = HttpUtility.UrlPathEncode(name.First().ToString().ToUpper() + name.Substring(1));

            var responseContent =
                RioRequest.Request(
                    "https://raider.io/api/v1/characters/profile?region=eu&realm="
                    + serverName + "&name=" + encodedName
                    + "&fields=mythic_plus_scores_by_season%3Acurrent%2Cmythic_plus_best_runs%3Aall").Result;

            using var reader = new StreamReader(await responseContent.ReadAsStreamAsync());
            var serializedStats = MythicPlusStats.FromJson(await reader.ReadToEndAsync());
            DiscordEmbedBuilder embed;

            try
            {
                embed = CreateEmbed(serializedStats);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(embed);
        }