From 8ed00518205cb41f7e575fb28e7620a871af60a9 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 23 Jul 2022 11:23:26 +0300 Subject: [PATCH] proper perm checks --- src/structure/components/infractions/Lockdown.js | 2 ++ src/structure/components/infractions/Nickname.js | 4 ++-- src/structure/components/infractions/Unlockdown.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structure/components/infractions/Lockdown.js b/src/structure/components/infractions/Lockdown.js index 3603fee..707902e 100644 --- a/src/structure/components/infractions/Lockdown.js +++ b/src/structure/components/infractions/Lockdown.js @@ -140,6 +140,8 @@ class LockdownInfraction extends Infraction { async verify() { + const perms = this.target.permissionsFor(this.guild.members.me); + if(perms.missing('ManageRoles').length) return this._fail('INFRACTION_LOCKDOWN_MISSING_PERMS'); return super._verify(); } diff --git a/src/structure/components/infractions/Nickname.js b/src/structure/components/infractions/Nickname.js index 55575ba..76f375e 100644 --- a/src/structure/components/infractions/Nickname.js +++ b/src/structure/components/infractions/Nickname.js @@ -53,7 +53,7 @@ class NicknameInfraction extends Infraction { } try { - this.member.setNickname(this.data.name, this._reason); + await this.member.setNickname(this.data.name, this._reason); } catch (e) { return this._fail('INFRACTION_ERROR'); } @@ -82,7 +82,7 @@ class NicknameInfraction extends Infraction { async verify() { const { highest } = this.member.roles; - if (highest.comparePositionTo(this.guild.members.me.roles.highest) > 0) { + if (highest.comparePositionTo(this.guild.members.me.roles.highest) > 0 || !this.guild.members.me.permissions.has('ManageNicknames')) { return this._fail('C_NICKNAME_MISSINGPERMISSIONS'); } diff --git a/src/structure/components/infractions/Unlockdown.js b/src/structure/components/infractions/Unlockdown.js index 3e01344..6086f92 100644 --- a/src/structure/components/infractions/Unlockdown.js +++ b/src/structure/components/infractions/Unlockdown.js @@ -95,6 +95,8 @@ class UnlockdownInfraction extends Infraction { async verify() { + const perms = this.target.permissionsFor(this.guild.members.me); + if (perms.missing('ManageRoles').length) return this._fail('INFRACTION_LOCKDOWN_MISSING_PERMS'); return super._verify(); }