Skip to content

Commit

Permalink
[backport] fix public roles exploit
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Oct 16, 2021
1 parent 763592c commit fdb8aa3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions server/bot/commands/admin/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export const handleGiverole: Command = {
)
const isPublicRole = role && publicRoles.split('|').includes(role.name)
if (!role) return { content: 'You have provided an invalid role name/ID, you ' + getInsult() + '.', error: true }
else if (!isPublicRole && !manageRoles) return insult
// Can the user manage this role?
if (role.position >= checkRolePosition(message.member) && !isPublicRole
else if (role.position >= checkRolePosition(message.member) && !isPublicRole
) return { content: `You cannot give this role. Pfft, overestimating their own powers now.`, error: true }
// Can the bot manage this role?
if (
else if (
role.position >= checkRolePosition(message.member.guild.members.get(client.user.id)) ||
!message.member.guild.members.get(client.user.id).permissions.has('manageRoles')
) return { content: `I lack permissions to give this role, you ${getInsult()}.`, error: true }
Expand Down Expand Up @@ -87,11 +88,12 @@ export const handleTakerole: Command = {
)
const isPublicRole = role && publicRoles.split('|').includes(role.name)
if (!role) return { content: 'You have provided an invalid role name/ID, you ' + getInsult() + '.', error: true }
else if (!isPublicRole && !manageRoles) return insult
// Can the user manage this role?
if (role.position >= checkRolePosition(message.member) && !isPublicRole
else if (role.position >= checkRolePosition(message.member) && !isPublicRole
) return { content: `You cannot take this role. Pfft, overestimating their own powers now.`, error: true }
// Can the bot manage this role?
if (
else if (
role.position >= checkRolePosition(message.member.guild.members.get(client.user.id)) ||
!message.member.guild.members.get(client.user.id).permissions.has('manageRoles')
) return { content: `I lack permissions to take this role, you ${getInsult()}.`, error: true }
Expand Down

0 comments on commit fdb8aa3

Please sign in to comment.