Hey everyone,
I’m looking to use the Roblox API to see if a user is in a specified group using the Roblox API.
Looking forward to your reply!
Hey everyone,
I’m looking to use the Roblox API to see if a user is in a specified group using the Roblox API.
Looking forward to your reply!
plr:IsInGroup(groupId)
here u go bud
Thanks for the reply, but I’m looking to check using a Discord Bot, not in-game. Is there any way to do that?
use it in game and then send a query to discord, that should work?
This is tough, theres no cloud api, etc way of doing this, however you could always have the user join a roblox game which verifies them. Alternatively, if you have access to the group itself you could use the GroupMembership List Group Memberships endpoint to get all the users in the group and then determine if the user is on that list.
Actually, by using the filtering methods, you can directly check for specific users.
filter=“user == ‘users/9876543210’”
Ah, alright, I’ll look into that.
I updated my original reply to give you some doc site links that will be helpful.
Got it Do you know if there is any API to get a users rank, then I could check if their rank ID is over 1?
Yes, using the same api endpoint, you will be given a membership object, that contains al the following information about a user, if theyre in the group.
{
"path": "groups/7/memberships/MjE1NTc",
"createTime": "2023-07-05T12:34:56Z",
"updateTime": "2023-07-05T12:34:56Z",
"user": "users/21557",
"role": "groups/7/roles/52"
}
Heres the path you need to go down to check if a player is in a group, and then get their rank.
Step 1. Get an api key that has permissions to read group data.
Step 2. Send a request to the roblox api with the following, where {groupid} and {userid} are replaced with your ids without the curly brackets. https://apis.roblox.com/cloud/v2/groups/{groupid}/memberships?maxPageSize=10&filter=user=='users/{userid}'
Step 3. Determine if the user is in the group based off of wether or not the api returned a membership object or not. Ex:
Player in group:
{
"groupMemberships": [{
"path": "groups/32603951/memberships/MjkwNjM0OTM5Mg",
"createTime": "2023-07-29T19:35:12.437Z",
"updateTime": "2023-09-09T15:42:53.287Z",
"user": "users/2906349392",
"role": "groups/32603951/roles/98840281"
}],
"nextPageToken": ""
}
Player not in group:
{
"groupMemberships": [],
"nextPageToken": ""
}
Step 4. Get the rank number of the user’s role, alternatively you can create your own table in your code which stores what role id is what rank so that you dont have to call the api each time, keep in mind that method doesnt account for new ranks.
To get the rank numbers of each role, you’ll have to call this api:
https://apis.roblox.com/cloud/v2/groups/{groupid}/roles
which returns an array of roles in the group:
{
"groupRoles": [{
"path": "groups/32603951/roles/98840281",
"id": "98840281",
"displayName": "ShareSphere Group Holder",
"rank": 255,
"memberCount": 1
}, {
"path": "groups/32603951/roles/100282523",
"id": "100282523",
"displayName": "ShareSphere Owner",
"rank": 254,
"memberCount": 1,
"permissions": {}
}, {
"path": "groups/32603951/roles/100078485",
"id": "100078485",
"displayName": "ShareSphere Developer",
"rank": 253,
"memberCount": 1
}, {
"path": "groups/32603951/roles/98840282",
"id": "98840282",
"displayName": "ShareSphere Staff",
"rank": 252,
"memberCount": 0
}, {
"path": "groups/32603951/roles/98840283",
"id": "98840283",
"displayName": "ShareSphere Fan",
"rank": 1,
"memberCount": 0
}, {
"path": "groups/32603951/roles/98840284",
"id": "98840284",
"displayName": "Guest",
"rank": 0,
"permissions": {}
}],
"nextPageToken": ""
}
From there just match the id to the one returned previously, and get it’s rank.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.