How to create a discord bot that access a games player count

Hi everyone! I am creating a discord bot however, how I could access a specific games player count. I couldn’t really find any API that has the ability to do this. Thank you

1 Like
1 Like

So the last link could help but I dont exactly know how that source code could get access to the roblox API

You should be able to fetch the player count from https://games.roblox.com/v1/games?universeIds=ID and use the Body.data.playing (returns int)

Body Example:

{"data":[{
"id":2055784388,
"rootPlaceId":5794718381,
"name":"no",
"description":"wow description",
"creator": {
"id":6033034,
"name":"🤔",
"type":"Group",
"isRNVAccount":false},
"price":null,
"allowedGearGenres":["All"],
"allowedGearCategories":[],"isGenreEnforced":true,
"copyingAllowed":false,
"playing":79,
"visits":22802229,
"maxPlayers":8,
"created":"2020-10-06T09:23:40.843Z",
"updated":"2021-10-08T16:19:56.383Z",
"studioAccessToApisAllowed":false,
"createVipServersAllowed":true,
"universeAvatarType":"MorphToR6",
"genre":"All",
"isAllGenre":true,
"isFavoritedByUser":false,
"favoritedCount":66481}
]}

I would use noblox.js, it’s very simple to use. To install it, run npm i noblox.js in your bot folder. Then use getPlaceInfo() like this:

const noblox = require('noblox.js');
const placeId = 1000000;

noblox.getPlaceInfo(placeId).then(info => {
 const placeInfo = info;

 console.log(info.VisitedCount);
}


/*will return this:
{
 "AssetId":1000000,
 "Name":"~\u0027s Place",
 "Description":"nothing",
 "Created":"1/1/1970",
 "Updated":"1/1/1970",
 "FavoritedCount":0,
 "Url":"https://www.roblox.com/games/1000000/s-Place",
 "ReportAbuseAbsoluteUrl":"https://www.roblox.com/abusereport/asset?id=1000000\u0026RedirectUrl=%2fgames%2f1000000%2fs-Place",
 "IsFavoritedByUser":false,
 "IsFavoritesUnavailable":false,
 "UserCanManagePlace":false,
 "VisitedCount":0, !!!!!!!!!!
 "MaxPlayers":100,
 "Builder":"@~",
 "BuilderId":1000000,
 "BuilderAbsoluteUrl":"https://www.roblox.com/users/1000000/profile/",
 "IsPlayable":false,
 "ReasonProhibited":"None",
 "ReasonProhibitedMessage":"None",
 "IsCopyingAllowed":false,
 "PlayButtonType":"FancyButtons",
 "AssetGenre":"All",
 "AssetGenreViewModel":{"DisplayName":"All","Id":1},
 "OnlineCount":0,
 "UniverseId":1000000,
 "UniverseRootPlaceId":1000000,
 "TotalUpVotes":0,
 "TotalDownVotes":0,
 "UserVote":null,
 "OverridesDefaultAvatar":false,
 "UsePortraitMode":false,
 "Price":0,
 "VoiceEnabled":false
}
*/