mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
4
typings/index.d.ts
vendored
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user