Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
fix(setRank): fix issues with IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
fisherjacobc committed Apr 17, 2022
1 parent 590ae94 commit 7ced84f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/group/setRank.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ module.exports = async (client, userId, newRank, groupId) => {
if (newRank > 255 || newRank < 1) throw new Error("INVALID NEW RANK")
let rolesets = await getRolesets(groupId || client.defaultGroup)

let rolesetFound = rolesets.roles.find((roleset) => {
if (roleset.rank === newRank) return true;
let rolesetFound = rolesets.data.roles.find((roleset) => {
return (roleset.rank === newRank)
})
if (!rolesetFound) throw new Error("ROLE ID NOT FOUND FOR THIS GROUP")
console.log(parseInt(rolesetFound.id))

await request.patch({
const req = await request.patch({
url: `${routes.v1.bases.groupsApi()}${routes.v1.groupMember(groupId || client.defaultGroup, userId)}`,
cookie: client.cookie,
token: client.token,
silenceErr: true,
body: {
roleId: newRank
roleId: parseInt(rolesetFound.id)
}
})

return req.data
}

0 comments on commit 7ced84f

Please sign in to comment.