Skip to content

Commit

Permalink
refactor(GuildMember): remove GuildMember#hasPermission (#5152)
Browse files Browse the repository at this point in the history
* refactor(GuildMember): remove GuildMember#hasPermission

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

* typings: remove `GuildMember#hasPermission`
  • Loading branch information
Ishmaam Khan authored Jan 24, 2021
1 parent 80e1afb commit 5401b92
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion src/structures/GuildEmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
14 changes: 0 additions & 14 deletions src/structures/GuildMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down

0 comments on commit 5401b92

Please sign in to comment.