示例#1
0
        public async Task ActiveGameInfo([Remainder][Summary("Summoner name")] string summonerName)
        {
            RiotApiResponseSummonerModel summoner = await _apiRequest.GetSummoner(summonerName);

            LeagueMatchModel match = await _apiRequest.GetMatch(summonerName);

            if (match.Status?.Status_code == "404") //When you try to get a match of a summoner thats not in a game it returns 404
            {
                await ReplyAsync($"{summoner.Name} is not in a game");

                return;
            }

            var embedBuilder = new EmbedBuilder()
            {
                Color = new Color(114, 137, 218),
                Title = $"{summoner.Name} is in a game and here's the info"
            };


            if (!_gamemodeMap.ContainsKey(match.GameMode))
            {
                string titleCase = char.ToUpper(match.GameMode[0]) + match.GameMode.Substring(1).ToLower();
                _gamemodeMap.Add(match.GameMode, titleCase);
                Console.WriteLine($"Added {match.GameMode} to dict -> {titleCase}");
            }

            embedBuilder.AddField("Gamemode", _gamemodeMap[match.GameMode]);


            var team1 = " ";
            var team2 = " ";

            foreach (var p in match.Participants)
            {
                if (p.TeamId == 100)
                {
                    team1 += p.SummonerName + "\n";
                }
                else
                {
                    team2 += p.SummonerName + "\n";
                }
            }

            embedBuilder.AddField("Blue team", team1, true);
            embedBuilder.AddField("Red team", team2, true);

            DateTimeOffset gameStartTime = DateTimeOffset.FromUnixTimeMilliseconds(match.GameStartTime);
            TimeSpan       gameTimeSpan  = DateTime.Now - gameStartTime;
            var            mins          = gameTimeSpan.Minutes + " min" + (gameTimeSpan.Minutes != 1 ? "s" : "");
            var            secs          = gameTimeSpan.Seconds + " sec" + (gameTimeSpan.Seconds != 1 ? "s" : "");

            embedBuilder.AddField("Length", $"{mins} and {secs}");

            await ReplyAsync("", false, embedBuilder.Build());
        }
示例#2
0
        public AuthModel addLM([FromBody] LeagueMatchModel model)
        {
            LeagueMatch lm = new LeagueMatch();

            lm.Id       = model.id;
            lm.idLeague = model.idLeague;
            lm.idMatch  = model.idMatch;

            _writeOnlyRepository.Create(lm);

            var authModel = new AuthModel {
            };

            return(authModel);
        }