public static async Task <Rank> GetCurrentRank(string UplayID) { TrackerDataSnippet data = await TRNHttpProvider.GetData(UplayID); Rank r = data.ToRank(); return(r); }
// Call RefreshRank() only when you hold the mutex to the internal dictionaries. private async Task RefreshRank(ulong discordID, string r6TabID) { try { TrackerDataSnippet data = await TRNHttpProvider.UpdateAndGetData(r6TabID); Rank fetchedRank = data.ToRank(); bool updateRequired = true; if (await _data.TrackingContains(discordID)) { Rank curRank = await _data.QueryRank(discordID); if (curRank.Equals(fetchedRank)) { updateRequired = false; } else { Console.WriteLine("The fetched rank and the stored rank disagree for the user " + discordID); Console.WriteLine($"The fetched rank equals {fetchedRank} and the stored rank is {curRank}."); } } else { Console.WriteLine("The user with DiscordID " + discordID + " is not yet in the database of ranks."); } if (updateRequired) { await _data.UpdateRanks(discordID, fetchedRank); await UpdateRoles(discordID, fetchedRank); } else { // System.Console.WriteLine("Ranks match for player " + player.Username); } } catch (RankParsingException) { Console.WriteLine("Failed to update rank for player " + discordID); } catch (System.Net.Http.HttpRequestException) { Console.WriteLine("Network unrechable, delaying update."); return; } }