diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-07 20:15:45 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-07 20:15:45 -0400 |
commit | 35d03eb54fe81c1d5c0359db67455b82f754e3f4 (patch) | |
tree | 5666ac26f6fee5e06c2c3a523fced614cb6723bf /src/lib/extensions/discord.js | |
parent | 198aeadfc73642498afcb1eb637e0de86ccc9308 (diff) | |
download | tanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.tar.gz tanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.tar.bz2 tanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.zip |
add owner bypasses and prevent blacklisted users from having their dms logged
Diffstat (limited to 'src/lib/extensions/discord.js')
-rw-r--r-- | src/lib/extensions/discord.js/BushGuildMember.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index 5575303..b5bc407 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -1,14 +1,14 @@ import { GuildMember, MessageEmbed, Partialize, Role } from 'discord.js'; import { RawGuildMemberData } from 'discord.js/typings/rawDataTypes'; import { ModLogType } from '../../models/ModLog'; -import { BushClient, BushUserResolvable } from '../discord-akairo/BushClient'; +import { BushClient } from '../discord-akairo/BushClient'; import { BushGuild } from './BushGuild'; import { BushRole } from './BushRole'; import { BushUser } from './BushUser'; interface BushPunishmentOptions { reason?: string | null; - moderator?: BushUserResolvable; + moderator?: BushGuildMember; } interface BushTimedPunishmentOptions extends BushPunishmentOptions { @@ -137,7 +137,7 @@ export class BushGuildMember extends GuildMember { } public async addRole(options: AddRoleOptions): Promise<AddRoleResponse> { - const ifShouldAddRole = this.#checkIfShouldAddRole(options.role); + const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator); if (ifShouldAddRole !== true) return ifShouldAddRole; let caseID: string | undefined = undefined; @@ -190,7 +190,7 @@ export class BushGuildMember extends GuildMember { } public async removeRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> { - const ifShouldAddRole = this.#checkIfShouldAddRole(options.role); + const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator); if (ifShouldAddRole !== true) return ifShouldAddRole; let caseID: string | undefined = undefined; @@ -240,8 +240,12 @@ export class BushGuildMember extends GuildMember { return ret; } - #checkIfShouldAddRole(role: BushRole | Role): true | 'user hierarchy' | 'role managed' | 'client hierarchy' { - if (this.roles.highest.position <= role.position && this.guild.ownerId !== this.id) { + #checkIfShouldAddRole( + role: BushRole | Role, + moderator?: BushGuildMember + ): true | 'user hierarchy' | 'role managed' | 'client hierarchy' { + if (moderator && moderator.roles.highest.position <= role.position /* && this.guild.ownerId !== this.id */) { + client.console.debug(`${this.roles.highest.position} <= ${role.position}`); return 'user hierarchy'; } else if (role.managed) { return 'role managed'; |