babelshift/SteamWebAPI2

Unable to get game info w/GetStoreAppDetailsAsync

CriticalFlaw opened this issue · 3 comments

I'm making a command for a Discord bot that pulls a random game from Steam. It gets a random AppID from a preloaded list then calls GetStoreAppDetailsAsync to get the game information. For certain games, namely Team Fortress 2 it works fine but for most others it throws an error, screenshot below.

Random RND = new Random();
SteamStore steam = new SteamStore();
var index = GlobalVariables.SteamAppList.Keys.ToArray()[RND.Next(0, GlobalVariables.SteamAppList.Keys.Count - 1)];
var app = await steam.GetStoreAppDetailsAsync(index);
var output = new DiscordEmbedBuilder()
.WithTitle(app.Name)
.WithThumbnailUrl(app.HeaderImage)
.WithFooter($"App ID: {app.SteamAppId.ToString()}")
.WithColor(DiscordColor.MidnightBlue);

Apologies if this is a newbie question, I'm fairly new to working with JSON and APIs.

Thanks!

Sorry, just realized you said TF2 is working but others aren't. I'll investigate others.

I changed the PcRequirements, MacRequirements, and LinuxRequirements properties to dynamic since it appears that the Steam Web API returns an object or an array for these fields depending on the game. The latest nuget package should fix this issue. Let me know. Thanks.

Downloaded the latest nuget package, it fixed the problem, thanks! Sometimes, when GetStoreAppDetailsAsync is called it'll return a null object reference exception, not sure what that's related to, so I've put it in a loop until a valid game is returned: CriticalFlaw/FlawBOT@8dc088e