public async Task <RiotApiResponseRankModel[]> GetSummonerRank(string summonerName) { RiotApiResponseSummonerModel summoner = await GetSummoner(summonerName); var urlRank = $"https://euw1.api.riotgames.com/lol/league/v4/entries/by-summoner/{summoner.Id}"; //Url to get ranked information of summoner. It only accepts summoner id return(await _apiHandler.ApiRequest <RiotApiResponseRankModel[]>(urlRank)); }
public async Task <LeagueMatchModel> GetMatch(string summonerName) { RiotApiResponseSummonerModel summoner = await GetSummoner(summonerName); var urlRank = $"https://euw1.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/{summoner.Id}"; //Url to get match. It only accepts summoner id return(await _apiHandler.ApiRequest <LeagueMatchModel>(urlRank)); }
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()); }