public jsonBeatSaber GetJsonStringBsStats(string BeatsaberApi) { WebRequest requestObjGet = WebRequest.Create(BeatsaberApi); requestObjGet.Method = "GET"; HttpWebResponse responseObjGet = null; responseObjGet = (HttpWebResponse)requestObjGet.GetResponse(); string stringresulttest = null; using (Stream stream = responseObjGet.GetResponseStream()) { StreamReader sr = new StreamReader(stream); stringresulttest = sr.ReadToEnd(); sr.Close(); } jsonBeatSaber Json = JsonConvert.DeserializeObject <jsonBeatSaber>(stringresulttest); return(Json); }
public async Task Getrecentplays(CommandContext ctx, string urlApi, string urlApi2, bool userSelf, DiscordMember member, string recentOrTop) { jsonScores json = GetJsonStringBsScores(urlApi); jsonBeatSaber jsonUser = GetJsonStringBsStats(urlApi2); var embed = new DiscordEmbedBuilder { Description = $"Beatsaber Id: {jsonUser.playerInfo.playerid}\n[Score Saber Website](https://scoresaber.com/u/{ jsonUser.playerInfo.playerid })", Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = $"https://new.scoresaber.com/{ jsonUser.playerInfo.avatar }" }, Color = DiscordColor.Orange }; if (recentOrTop == "recent") { embed.WithTitle($"Most recent Beatsaber songs played for {jsonUser.playerInfo.name}"); } if (recentOrTop == "top") { embed.WithTitle($"Top Beatsaber songs played for {jsonUser.playerInfo.name}"); } foreach (scores song in json.scores) { embed.AddField( $"{song.songAuthorName} - {song.name}\nMapped by {song.levelAuthorName}", $"Score: {song.score}\n" + $"PP: {song.pp}\n" + $"Rank: {song.rank}\n" + $"Difficulty: {song.diff}"); } if (userSelf == true) { embed.WithFooter("If you wish to change your Beatsaber Id please click the gear emoji down below. (will disappear after 60 Seconds)"); } await ctx.Message.DeleteAsync("cleanup"); var embedMessage = await ctx.Channel.SendMessageAsync("", embed : embed); if (userSelf == true) { DiscordEmoji gearEmoji = DiscordEmoji.FromName(ctx.Client, ":gear:"); await embedMessage.CreateReactionAsync(gearEmoji).ConfigureAwait(false); var interactivity = ctx.Client.GetInteractivity(); try { var ReactionResult = await interactivity.WaitForReactionAsync( x => x.Message == embedMessage && x.User == ctx.User && (x.Emoji == gearEmoji)).ConfigureAwait(false); if (ReactionResult.Result.Emoji == gearEmoji) { await embedMessage.DeleteAsync(null); await ValidateOrSetId(ctx, ctx.Member.Id); return; } } catch { await embedMessage.DeleteAllReactionsAsync(null); } } }
public async Task GetBasicInfo(CommandContext ctx, string urlApi, bool userSelf, DiscordMember member) { jsonBeatSaber json = GetJsonStringBsStats(urlApi); var embed = new DiscordEmbedBuilder { Title = $"Beatsaber stats for {json.playerInfo.name}", Description = $"Beatsaber Id: {json.playerInfo.playerid}\n[Score Saber Website](https://scoresaber.com/u/{ json.playerInfo.playerid })\n\nFor more stats on Beatsaber try w!beatsaber Top, or w!beatsaber Recent)", Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = $"https://new.scoresaber.com/{ json.playerInfo.avatar }" }, Color = DiscordColor.Orange }; if (userSelf == true) { embed.WithFooter("If you wish to change your Beatsaber Id please click the gear emoji down below. (will disappear after 60 Seconds)"); } embed.AddField( "Rank Status:", $"PP: {json.playerInfo.pp}\n" + $"Global Rank: {json.playerInfo.rank}\n" + $"Country rank in {json.playerInfo.country}: {json.playerInfo.countryRank}\n" + $"Average ranked accuracy: {json.scoreStats.averageRankedAccuracy}" , true); embed.AddField( "Score Stats", $"Total score: {json.scoreStats.totalScore}\n" + $"Total play count: {json.scoreStats.totalPlayCount}\n" + $"Total ranked score: {json.scoreStats.totalRankedScore}\n" + $"Ranked play count: {json.scoreStats.rankedPlayCount}" , true); await ctx.Message.DeleteAsync("cleanup"); var embedMessage = await ctx.Channel.SendMessageAsync("", embed : embed); if (userSelf == true) { DiscordEmoji gearEmoji = DiscordEmoji.FromName(ctx.Client, ":gear:"); await embedMessage.CreateReactionAsync(gearEmoji).ConfigureAwait(false); var interactivity = ctx.Client.GetInteractivity(); try { var ReactionResult = await interactivity.WaitForReactionAsync( x => x.Message == embedMessage && x.User == ctx.User && (x.Emoji == gearEmoji)).ConfigureAwait(false); if (ReactionResult.Result.Emoji == gearEmoji) { await embedMessage.DeleteAsync(null); await ValidateOrSetId(ctx, ctx.Member.Id); return; } } catch { await embedMessage.DeleteAllReactionsAsync(null); } } }