mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
refactor(GuildPreviewEmoji): make roles an array (#5720)
This commit is contained in:
@@ -21,14 +21,6 @@ class BaseGuildEmoji extends Emoji {
|
||||
this.managed = null;
|
||||
this.available = null;
|
||||
|
||||
/**
|
||||
* Array of role ids this emoji is active for
|
||||
* @name BaseGuildEmoji#_roles
|
||||
* @type {Snowflake[]}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, '_roles', { value: [], writable: true });
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
@@ -58,8 +50,6 @@ class BaseGuildEmoji extends Emoji {
|
||||
*/
|
||||
this.available = data.available;
|
||||
}
|
||||
|
||||
if (data.roles) this._roles = data.roles;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,14 @@ class GuildEmoji extends BaseGuildEmoji {
|
||||
* @type {?User}
|
||||
*/
|
||||
this.author = null;
|
||||
|
||||
/**
|
||||
* Array of role ids this emoji is active for
|
||||
* @name GuildEmoji#_roles
|
||||
* @type {Snowflake[]}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, '_roles', { value: [], writable: true });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +47,9 @@ class GuildEmoji extends BaseGuildEmoji {
|
||||
|
||||
_patch(data) {
|
||||
super._patch(data);
|
||||
if (typeof data.user !== 'undefined') this.author = this.client.users.add(data.user);
|
||||
|
||||
if (data.user) this.author = this.client.users.add(data.user);
|
||||
if (data.roles) this._roles = data.roles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,13 +13,14 @@ class GuildPreviewEmoji extends BaseGuildEmoji {
|
||||
* @name GuildPreviewEmoji#guild
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set of roles this emoji is active for
|
||||
* @type {Set<Snowflake>}
|
||||
* @readonly
|
||||
*/
|
||||
get roles() {
|
||||
return new Set(this._roles);
|
||||
constructor(client, data, guild) {
|
||||
super(client, data, guild);
|
||||
|
||||
/**
|
||||
* The roles this emoji is active for
|
||||
* @type {Snowflake[]}
|
||||
*/
|
||||
this.roles = data.roles;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user