forked from Galactic/galactic-bot
add protection role verification
This commit is contained in:
parent
d83697f8d8
commit
6e289fe326
@ -265,9 +265,12 @@ You can increase the amount of targets by upgrading to premium.
|
||||
[INFRACTION_ERROR]
|
||||
an error occured
|
||||
|
||||
[INFRACTION_PROTECTIONERROR]
|
||||
[INFRACTION_PROTECTIONPOSITIONERROR]
|
||||
they have hierarchy over you
|
||||
|
||||
[INFRACTION_PROTECTIONROLEERROR]
|
||||
their roles are protected
|
||||
|
||||
[INFRACTION_AUTOMODESCALATION]
|
||||
This action was automatically escalated by auto-moderation.
|
||||
|
||||
|
@ -267,16 +267,23 @@ class Infraction {
|
||||
}
|
||||
|
||||
async _verify() {
|
||||
const { protection } = await this.guild.settings();
|
||||
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
|
||||
if (this.guild && protection.enabled && this.targetType === 'USER') {
|
||||
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(protection.type === 'position') {
|
||||
const executorHighest = executor.roles.highest;
|
||||
const targetHighest = target.roles.highest;
|
||||
if (executorHighest.comparePositionTo(targetHighest) < 0) {
|
||||
return this._fail('INFRACTION_PROTECTIONERROR');
|
||||
return this._fail('INFRACTION_PROTECTIONPOSITIONERROR');
|
||||
}
|
||||
} else if(protection.type === 'role') {
|
||||
const contains = target.roles.cache.some((r) => protection.roles.includes(r.id));
|
||||
if(contains) {
|
||||
return this._fail('INFRACTION_PROTECTIONROLEERROR');
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._succeed();
|
||||
|
Loading…
Reference in New Issue
Block a user