Hello so I was wondering if there is a way to display on discord how many members a roblox group has so something like this:
I’m not very good at scripting so I have no idea how to do this.
Hello so I was wondering if there is a way to display on discord how many members a roblox group has so something like this:
I’m not very good at scripting so I have no idea how to do this.
To get the number of members in the group, use /v1/groups/{groupId} from the Groups API. This will return information about the group you specify in a JSON format. In that data, there’s an indice called “memberCount”, this is what you’re looking for to check the number of users in the group.
For the bot to consistently update the number of members in the group, poll from the aforementioned group information endpoint. Avoid spamming the endpoints so you don’t get flagged and blocked from querying them, make sure to be mindful of rate limits, allowances and all.
The rest is up to you here. These two are the most basic things you need to get this system done, so the rest comes down to putting the pieces together. Make a web server, a bot or whatever that can automate these tasks for you: query from the group endpoint, use Discord API to send a message to a channel, rinse and repeat across a certain interval.
I didn’t mention anything about the goals or members left to go because it should be fairly self explanatory how you can get that done. You can either use a formula to calculate your next milestones or manually input it. You can also, if you have a bot, just use a milestone configuration command which can semi-automate the task of changing the milestone. Members left is just simple math.
Well, you’ll need a discord bot. To do this, you can simply do:
const discord = require('discord.js')
const client = new Client({
disableEveryone: true
})
client.login('YOUR BOT TOKEN HERE')
That’s basic thing you need to do. Also you will need to install Visual Studio Code and node.js for this. Or, you can use repl for free hosting. You can see how to host on youtube. Anyways, let’s get back into the topic. Now, after you have that, you want to get the bot token by going to the Discord Developer Portal. Go to Applications, create new applications, bot, add bot, copy token and paste the token on the client.login(‘’).
Next, you want to add the code. If you want to use a webhook, create a webook on the channel. Then add this code on the top.
const axios = require('axios');
let GROUP_ID =
let GOAL =
let count = 0
let wid = "" \\ The webhookID.
let wtoken = "" \ The webhook token.
let webhook = new discord.WebhookClient(wid, wtoken)
So, just fill that up. Group ID is the groupID of your group, obviosuly. Count just stays at 0. You can get the webhookokID by copy the webhook and paste it on any channel. The number part of the link is the id of the webook. The token can be found next to the id. Once you’ve done that, you can paste this code.
async function updateCount() {
let response = await axios.get(`https://groups.roblox.com/v1/groups/${GROUP_ID}/`)
let response_count = response.data.memberCount
console.log("got request")
if (count < response_count) {
console.log(response_count, count)
webhook.send(`:tada: We're now at ${response_count} members in our group! Only ${GOAL - response_count} to go until ${GOAL}!`)
if (count == 0) {
count = response_count
return;
}
count = response_count
}
}
setInterval(() => {
updateCount()
}, 60000);
There you go! Your member count has been setup! Also, it will send the message event if its the same amount of members due to the roblox api. But, it still works properly. Enjoy! I’ll just paste all of it here just to not make you confuse about it.
const discord = require('discord.js')
const client = new Client({
disableEveryone: true
})
const axios = require('axios');
let GROUP_ID =
let GOAL =
let count = 0
let wid = "" \\ The webhookID.
let wtoken = "" \ The webhook token.
let webhook = new discord.WebhookClient(wid, wtoken)
async function updateCount() {
let response = await axios.get(`https://groups.roblox.com/v1/groups/${GROUP_ID}/`)
let response_count = response.data.memberCount
console.log("got request")
if (count < response_count) {
console.log(response_count, count)
webhook.send(`:tada: We're now at ${response_count} members in our group! Only ${GOAL - response_count} to go until ${GOAL}!`)
if (count == 0) {
count = response_count
return;
}
count = response_count
}
}
setInterval(() => {
updateCount()
}, 60000);
client.login('YOUR BOT TOKEN HERE')
If you have any question, feel free to DM me at clloudy.js#0074