From 5401b92aac72db3a60e4cd6f61f180294ca9c929 Mon Sep 17 00:00:00 2001 From: Ishmaam Khan Date: Sun, 24 Jan 2021 16:50:58 +0600 Subject: [PATCH] refactor(GuildMember): remove GuildMember#hasPermission (#5152) * refactor(GuildMember): remove GuildMember#hasPermission * refactor(GuildEmoji): remove use for `GuildMember#hasPermission` * typings: remove `GuildMember#hasPermission` --- src/structures/GuildEmoji.js | 2 +- src/structures/GuildMember.js | 14 -------------- typings/index.d.ts | 4 ---- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/structures/GuildEmoji.js b/src/structures/GuildEmoji.js index f4df468b7..79c7104d0 100644 --- a/src/structures/GuildEmoji.js +++ b/src/structures/GuildEmoji.js @@ -49,7 +49,7 @@ class GuildEmoji extends BaseGuildEmoji { */ get deletable() { if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME'); - return !this.managed && this.guild.me.hasPermission(Permissions.FLAGS.MANAGE_EMOJIS); + return !this.managed && this.guild.me.permissions.has(Permissions.FLAGS.MANAGE_EMOJIS); } /** diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 8f5da28dc..f29c9ff7d 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -264,20 +264,6 @@ class GuildMember extends Base { return channel.memberPermissions(this); } - /** - * Checks if any of this member's roles have a permission. - * @param {PermissionResolvable} permission Permission(s) to check for - * @param {Object} [options] Options - * @param {boolean} [options.checkAdmin=true] Whether to allow the administrator permission to override - * @param {boolean} [options.checkOwner=true] Whether to allow being the guild's owner to override - * @returns {boolean} - */ - hasPermission(permission, { checkAdmin = true, checkOwner = true } = {}) { - if (checkOwner && this.user.id === this.guild.ownerID) return true; - const permissions = new Permissions(this.roles.cache.map(role => role.permissions)); - return permissions.has(permission, checkAdmin); - } - /** * The data for editing a guild member. * @typedef {Object} GuildMemberEditData diff --git a/typings/index.d.ts b/typings/index.d.ts index 12f392510..f86e4611d 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -823,10 +823,6 @@ declare module 'discord.js' { public createDM(force?: boolean): Promise; public deleteDM(): Promise; public edit(data: GuildMemberEditData, reason?: string): Promise; - public hasPermission( - permission: PermissionResolvable, - options?: { checkAdmin?: boolean; checkOwner?: boolean }, - ): boolean; public kick(reason?: string): Promise; public permissionsIn(channel: ChannelResolvable): Readonly; public setNickname(nickname: string | null, reason?: string): Promise;