refactor(GuildMember): remove GuildMember#hasPermission (#5152)

* refactor(GuildMember): remove GuildMember#hasPermission

* refactor(GuildEmoji): remove use for `GuildMember#hasPermission`

* typings: remove `GuildMember#hasPermission`
This commit is contained in:
Ishmaam Khan
2021-01-24 16:50:58 +06:00
committed by GitHub
parent 80e1afb654
commit 5401b92aac
3 changed files with 1 additions and 19 deletions

View File

@@ -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);
}
/**

View File

@@ -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

4
typings/index.d.ts vendored
View File

@@ -823,10 +823,6 @@ declare module 'discord.js' {
public createDM(force?: boolean): Promise<DMChannel>;
public deleteDM(): Promise<DMChannel>;
public edit(data: GuildMemberEditData, reason?: string): Promise<GuildMember>;
public hasPermission(
permission: PermissionResolvable,
options?: { checkAdmin?: boolean; checkOwner?: boolean },
): boolean;
public kick(reason?: string): Promise<GuildMember>;
public permissionsIn(channel: ChannelResolvable): Readonly<Permissions>;
public setNickname(nickname: string | null, reason?: string): Promise<GuildMember>;