Fetch group members (discord.js)

How would I make a discord.js command which fetches the amount of members in a specific Roblox group? I was given this but I have no idea where to start…

Any help would be appreciated. Thank you!

Take a look here: https://api.roblox.com/docs#Groups
And here: https://cdn.discordapp.com/attachments/639110314742251521/714249179685453885/unknown.png (link you provided)
If you are using discord.js, you can easily use something like the node.js http module to fetch data from a given URL.

Honestly, this still makes absolutely no sense to be. Which package would I use and how do I start off my code?

Ok give me a few mins to get an example up

Alright.

30 charactersssssssss

Ok, (sorry it took so long I went afk).
I threw together a rough example using request in node.js (its a lot simpler than using http.get) and here is what I tried:

var request = require("request"); // You have to install this and include it in your package.json

const groupID = 6151151; // ID of your group goes here
var URL = "https://groups.roblox.com/v1/groups/" + groupID;

function getData(field)
{
    return new Promise((resolve, reject) => { 
      request(
        { uri: URL },
        function(error, response, body) 
        {
            if (response.statusCode == 200) resolve(JSON.parse(body)[field])
            else reject("Something went wrong!") // obviously put a more descriptive error message
        }
      );
    });
}
getData("memberCount").then((count) => console.log(count)).catch(e => console.error(e)) // prints 13 (see screenshot below to see full data)

I tested this and it works. It might not the best way to do this (my nodejs is rusty lol) but until someone provides a better answer you can use it :smiley:

Note, if you want to get a different field from the URL, just change the parameter of “getData” like so:

getData("name").then((name) => console.log(name)) // prints "Dairy Queen | Happy Tastes Good"
The group I used for testing returned this when I pulled the full information from the URL

1 Like

Thank you so much, I greatly appreciate you taking up your time to do that for me! :slight_smile: