mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +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.managed = null;
|
||||||
this.available = 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);
|
this._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +50,6 @@ class BaseGuildEmoji extends Emoji {
|
|||||||
*/
|
*/
|
||||||
this.available = data.available;
|
this.available = data.available;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.roles) this._roles = data.roles;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ class GuildEmoji extends BaseGuildEmoji {
|
|||||||
* @type {?User}
|
* @type {?User}
|
||||||
*/
|
*/
|
||||||
this.author = null;
|
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) {
|
_patch(data) {
|
||||||
super._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
|
* @name GuildPreviewEmoji#guild
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
constructor(client, data, guild) {
|
||||||
* Set of roles this emoji is active for
|
super(client, data, guild);
|
||||||
* @type {Set<Snowflake>}
|
|
||||||
* @readonly
|
/**
|
||||||
*/
|
* The roles this emoji is active for
|
||||||
get roles() {
|
* @type {Snowflake[]}
|
||||||
return new Set(this._roles);
|
*/
|
||||||
|
this.roles = data.roles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
typings/index.d.ts
vendored
9
typings/index.d.ts
vendored
@@ -248,9 +248,7 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class BaseGuildEmoji extends Emoji {
|
export class BaseGuildEmoji extends Emoji {
|
||||||
constructor(client: Client, data: unknown, guild: Guild);
|
constructor(client: Client, data: unknown, guild: Guild | GuildPreview);
|
||||||
private _roles: Snowflake[];
|
|
||||||
|
|
||||||
public available: boolean | null;
|
public available: boolean | null;
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
@@ -924,6 +922,9 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GuildEmoji extends BaseGuildEmoji {
|
export class GuildEmoji extends BaseGuildEmoji {
|
||||||
|
constructor(client: Client, data: unknown, guild: Guild);
|
||||||
|
private _roles: Snowflake[];
|
||||||
|
|
||||||
public readonly deletable: boolean;
|
public readonly deletable: boolean;
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
public author: User | null;
|
public author: User | null;
|
||||||
@@ -1020,7 +1021,7 @@ declare module 'discord.js' {
|
|||||||
export class GuildPreviewEmoji extends BaseGuildEmoji {
|
export class GuildPreviewEmoji extends BaseGuildEmoji {
|
||||||
constructor(client: Client, data: unknown, guild: GuildPreview);
|
constructor(client: Client, data: unknown, guild: GuildPreview);
|
||||||
public guild: GuildPreview;
|
public guild: GuildPreview;
|
||||||
public readonly roles: Set<Snowflake>;
|
public roles: Snowflake[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HTTPError extends Error {
|
export class HTTPError extends Error {
|
||||||
|
|||||||
Reference in New Issue
Block a user