@quenty/grouputils 10.20.1 → 10.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.20.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/grouputils@10.20.1...@quenty/grouputils@10.20.2) (2026-06-03)
7
+
8
+ **Note:** Version bump only for package @quenty/grouputils
9
+
6
10
  ## [10.20.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/grouputils@10.20.0...@quenty/grouputils@10.20.1) (2026-05-30)
7
11
 
8
12
  **Note:** Version bump only for package @quenty/grouputils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/grouputils",
3
- "version": "10.20.1",
3
+ "version": "10.20.2",
4
4
  "description": "Group utility functions for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "598b2b62b36bdcbdbbd56f7db10c399831cc6eba"
38
+ "gitHead": "1acafc712ce34f5dbaa70bb23b16da95e9cd3f82"
39
39
  }
@@ -13,6 +13,58 @@ local Promise = require("Promise")
13
13
 
14
14
  local GroupUtils = {}
15
15
 
16
+ type RoleTable = {
17
+ Id: number,
18
+ Name: string,
19
+ Rank: number,
20
+ }
21
+ type RoleTableList = { RoleTable }
22
+ type GetRolesInGroupAsyncResult = {
23
+ IsMember: boolean,
24
+ Roles: RoleTableList,
25
+ }
26
+
27
+ local function _getHighestRoleTable(roleTableList: RoleTableList): RoleTable?
28
+ local highestRank = 0
29
+ local highestRankRoleTable: RoleTable? = nil
30
+ for _, roleTable in roleTableList do
31
+ if roleTable.Rank > highestRank then
32
+ highestRank = roleTable.Rank
33
+ highestRankRoleTable = roleTable
34
+ end
35
+ end
36
+ return highestRankRoleTable
37
+ end
38
+
39
+ type GetGroupDictionary = {
40
+ Name: string,
41
+ Id: number,
42
+ EmblemUrl: string,
43
+ EmbelmId: number,
44
+ Rank: number, -- deprecated, but probably won't annoy lint:luau
45
+ Role: string, -- deprecated, but probably won't annoy lint:luau
46
+ IsPrimary: boolean,
47
+ IsInClan: boolean, -- deprecated, always false
48
+ }
49
+ type GetGroupsAsyncResult = { GetGroupDictionary }
50
+
51
+ local function _getRankAndRoleFallback(userId: number, groupId: number): (number, string?)
52
+ -- euvin: i yoinked this from
53
+ -- https://devforum.roblox.com/t/groupservicegetrolesingroupasync-is-not-enabled-yet-wiki-tells-me-to-use-it/4660969
54
+
55
+ --? The GetRankInGroup method is deprecated and unstable now.
56
+ --? https://devforum.roblox.com/t/excessive-rate-limits-when-checking-gamepasses-group-ranks/3549665
57
+ local groups = GroupService:GetGroupsAsync(userId) :: GetGroupsAsyncResult
58
+
59
+ for _, GroupInfo: GetGroupDictionary in groups do
60
+ if GroupInfo.Id == groupId then
61
+ return GroupInfo.Rank, GroupInfo.Role
62
+ end
63
+ end
64
+
65
+ return 0, nil
66
+ end
67
+
16
68
  --[=[
17
69
  Retrieves the rank of the player in the group.
18
70
 
@@ -25,11 +77,25 @@ function GroupUtils.promiseRankInGroup(player: Player, groupId: number): Promise
25
77
  assert(type(groupId) == "number", "Bad groupId")
26
78
 
27
79
  return Promise.spawn(function(resolve, reject)
28
- local rank = nil
80
+ local rank: number = nil
29
81
  local ok, err = pcall(function()
30
- -- TODO: Replace with GroupService:GetRolesInGroupAsync() once enabled
31
- rank = player:GetRankInGroupAsync(groupId)
82
+ -- GetRankInGroupAsync is deprecated, changed from GetRankInGroupAsync to GetRolesInGroupAsync
83
+ -- ... but GetRolesInGroupAsync fails for some reason and hasn't been fixed (June 2, 2026)
84
+ -- so we will fall back to a deprecated method anyway
85
+ local result = GroupService:GetRolesInGroupAsync(player.UserId, groupId) :: GetRolesInGroupAsyncResult
86
+ if result.IsMember then
87
+ local highestRoleTable = _getHighestRoleTable(result.Roles)
88
+ if highestRoleTable then
89
+ rank = highestRoleTable.Rank
90
+ end
91
+ end
32
92
  end)
93
+ if not rank then
94
+ ok, err = pcall(function()
95
+ local gotRank, _ = _getRankAndRoleFallback(player.UserId, groupId)
96
+ rank = gotRank
97
+ end)
98
+ end
33
99
 
34
100
  if not ok then
35
101
  return reject(err)
@@ -55,12 +121,24 @@ function GroupUtils.promiseRoleInGroup(player: Player, groupId: number): Promise
55
121
  assert(type(groupId) == "number", "Bad groupId")
56
122
 
57
123
  return Promise.spawn(function(resolve, reject)
58
- local role = nil
124
+ local role: string? = nil
59
125
  local ok, err = pcall(function()
60
- -- TODO: Replace with GroupService:GetRolesInGroupAsync() once enabled
61
- role = player:GetRoleInGroupAsync(groupId)
126
+ local result = GroupService:GetRolesInGroupAsync(player.UserId, groupId) :: GetRolesInGroupAsyncResult
127
+ if result.IsMember then
128
+ local highestRoleTable = _getHighestRoleTable(result.Roles)
129
+ if highestRoleTable then
130
+ role = highestRoleTable.Name
131
+ end
132
+ end
62
133
  end)
63
134
 
135
+ if not role then
136
+ ok, err = pcall(function()
137
+ local _, gotRole = _getRankAndRoleFallback(player.UserId, groupId)
138
+ role = gotRole
139
+ end)
140
+ end
141
+
64
142
  if not ok then
65
143
  return reject(err)
66
144
  end