From e49eea567211c25b745e2e8d26ff0c5c092eaea5 Mon Sep 17 00:00:00 2001 From: Navy Date: Tue, 28 Jul 2020 14:11:48 +0300 Subject: [PATCH] perm checks --- structure/moderation/interfaces/Infraction.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/structure/moderation/interfaces/Infraction.js b/structure/moderation/interfaces/Infraction.js index b8b4407..56daef3 100644 --- a/structure/moderation/interfaces/Infraction.js +++ b/structure/moderation/interfaces/Infraction.js @@ -221,11 +221,15 @@ class Infraction { return this._verify(); } - _verify() { - if (this.guild && this.guild._settings.protection.enabled) { + async _verify() { + if (this.executor.id === this.guild.ownerID) return this._succeed(); + if (this.guild && this.guild._settings.protection.enabled && this.targetType === 'user') { //Idk what the thought process here has been, but the user object does not have roles, and the executor is a user object - const executorHighest = this.guild.members.cache.get(this.executor.id).roles.highest; //this.executor.roles.highest; - const targetHighest = this.guild.members.cache.get(this.target.id).roles.highest; //this.member.roles.highest; + const executor = await this.guild.members.fetch(this.executor.id).catch(); + const target = await this.guild.members.fetch(this.target.id).catch(); + if (!target) return this._succeed(); + const executorHighest = executor.roles.highest; //this.executor.roles.highest; + const targetHighest = target.roles.highest; //this.member.roles.highest; if(executorHighest.comparePositionTo(targetHighest) > 0) { return this._fail('INFRACTION_PROTECTIONERROR'); }