3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 06:51:51 +00:00

canActOn: add option to allow same level

This commit is contained in:
Dragory 2020-01-12 11:38:12 +02:00
parent 63b3519ac4
commit c1b7967d10

View file

@ -71,14 +71,14 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
throw new PluginRuntimeError(message, this.runtimePluginName, this.guildId); throw new PluginRuntimeError(message, this.runtimePluginName, this.guildId);
} }
protected canActOn(member1, member2) { protected canActOn(member1: Member, member2: Member, allowSameLevel = false) {
if (member1.id === member2.id || member2.id === this.bot.user.id) { if (member2.id === this.bot.user.id) {
return false; return false;
} }
const ourLevel = this.getMemberLevel(member1); const ourLevel = this.getMemberLevel(member1);
const memberLevel = this.getMemberLevel(member2); const memberLevel = this.getMemberLevel(member2);
return ourLevel > memberLevel; return allowSameLevel ? ourLevel >= memberLevel : ourLevel > memberLevel;
} }
/** /**