//Thanks to peppy no longer needed /*public static async Task<bool> ReplayExists(OsuGameModes gameMode, object beatmapID, object userID) => (await NetworkHandler.DownloadJSON( * $"{api}get_replay?" + * $"k={Keys.API_KEYS["Osu"]}&" + * $"m={OsuGameModesConverter.ToOfficialNumeration(gameMode)}&" + * $"b={beatmapID}&" + * $"u={userID}", 2)).Contains("content");*/ private static async Task <T[]> DownloadObjects <T>(string url, int maxAttempts, SocketUserMessage logger, bool tolerateNull = false, object additional = null) { string json = await NetworkHandler.DownloadJSON(url, maxAttempts); try { object[] rawTypes = JsonConvert.DeserializeObject <object[]>(json); if (rawTypes.Length == 0) { if (!tolerateNull) { throw new ArgumentNullException(); } else { return(new T[1]); //so it can return null when obtaining a singular object with [0] } } T[] converted = new T[rawTypes.Length]; for (int i = 0; i < rawTypes.Length; i++) { converted[i] = (T)(additional != null ? Activator.CreateInstance(typeof(T), rawTypes[i], additional) : Activator.CreateInstance(typeof(T), rawTypes[i])); } return(converted); } catch (ArgumentNullException e) { if (logger != null) { if (typeof(OsuUser) == typeof(T)) { await logger.EditAsync( "User was unable to be retrieved from the official osu! api. ❔\n" + "Possible instances: bound user, top 3 players of a beatmap", null); } if (typeof(OsuBeatmap) == typeof(T)) { await logger.EditAsync("This beatmap(or beatmap pack) was unable to be retrieved from the official osu! api. ❔", null); } else if (typeof(OsuUserRecent) == typeof(T)) { await logger.EditAsync($"No recent plays have been found for game mode {OsuGameModesConverter.GameModeName((OsuGameModes)additional)}. 🔎", null); } else if (typeof(OsuScore) == typeof(T)) { await logger.EditAsync($"Scores were unable to be retrieved from the official osu! api. 🔎", null); } throw e; } } return(default(T[])); }
public async Task GetGame(string app) { string json = await NetworkHandler.DownloadJSON($"http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/?key={Keys.API_KEYS["Steam"]}&appid={app}&", 1); EmbedBuilder eb = new EmbedBuilder(); eb.AddField(x => { x.Name = "test"; x.Value = "test"; }); await Context.Channel.SendMessageAsync($"http://cdn.akamai.steamstatic.com/steam/apps/{app}/movie480.webm"); }