public async Task ResolveVanityURL(string name = null) { if (name == null) { name = Context.User.Username; } await ReplyAsync(((await _steamUser.ResolveVanityUrlAsync(name).ConfigureAwait(false)).Data).ToString()).ConfigureAwait(false); }
public async Task CSGOStats(string name = null) { if (name == null) { name = Context.User.Username; } Dictionary <string, double> dict = (await _steamUserStats.GetUserStatsForGameAsync( (await _steamUser.ResolveVanityUrlAsync(name)).Data, 730) ).Data.Stats.ToDictionary(x => x.Name, x => x.Value); await ReplyAsync("", embed : new EmbedBuilder() { Title = $"CS:GO stats for {name}", Color = _settings.GetColor() } .AddField(f => { f.IsInline = true; f.Name = "Kills"; f.Value = dict["total_kills"].ToString(); }) .AddField(f => { f.IsInline = true; f.Name = "Deaths"; f.Value = dict["total_deaths"].ToString(); }) .AddField(f => { f.IsInline = true; f.Name = "K/D"; f.Value = Math.Round(dict["total_kills"] / dict["total_deaths"], 2).ToString(); }) .AddField(f => { f.IsInline = true; f.Name = "Headshots"; f.Value = Math.Round(100.0 / dict["total_kills"] * dict["total_kills_headshot"], 2) + "%"; }) .AddField(f => { f.IsInline = true; f.Name = "Accuracy"; f.Value = Math.Round(100.0 / dict["total_shots_fired"] * dict["total_shots_hit"], 2) + "%"; }) .AddField(f => { f.IsInline = true; f.Name = "Playtime"; f.Value = Math.Round(dict["total_time_played"] / 60 / 60, 2) + " hours"; }).Build()); }
/// <summary> /// Queries the Steam Web API for a 64-bit Steam ID based on a provided string value. /// </summary> /// <param name="steamUser"></param> /// <param name="value"></param> /// <returns></returns> private static async Task <ulong> ResolveSteamIdFromValueAsync(ISteamUser steamUser, string value) { ulong steamId64 = 0; var steamId = await steamUser.ResolveVanityUrlAsync(value); steamId64 = steamId.Data; return(steamId64); }
private async Task <(bool success, ulong userID)> TryParseUserId(string steamID) { if (steamID.Length != 17 || !UInt64.TryParse(steamID, out ulong userID)) { try { userID = (await steamUser.ResolveVanityUrlAsync(steamID)).Data; logger.LogDebug($"SteamID {steamID} resolved to UserID {userID}."); } catch (VanityUrlNotResolvedException) { return(false, 0); } } return(true, userID); }
public async Task <ulong> PlayerInfoVanity(string steamId) { ISteamWebResponse <ulong> playerId = await steamInterface.ResolveVanityUrlAsync(steamId); return(playerId.Data); }