For some reason, I keep getting the following response from NightBot when I try the command.
Nightbot: Cannot read property 'stats' of undefined
When I navigate to https://owapi.net/api/v3/u/Dad-12262/stats in my browser, I correctly get data in the .us attribute of the object, so that’s why I’m confused about the error message from the Nightbot.
The problem is that $(urlfetch https://owapi.net/api/v3/u/Dad-12262/stats) is being replaced with [Response must be less than 400 characters]. This is because Nightbot doesn’t allow the standard $(urlfetch ...) to fetch more than 400 characters. You can, however, use $(urlfetch json ...) to fetch any amount of characters.
It is also good practice, but not necessary, to use JSON.parse on a JSON string rather than inserting JSON directly into your JavaScript code.
Also, I visited that URL, and us.stats.competitive.overall_stats.comprank was null, so I made the command check for that and say “None” instead of “null”.