From ef2c1bfa77746559a80decb4e96814e78f3ec1c9 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Fri, 30 May 2025 14:06:06 -0500 Subject: [PATCH] fix(Emoji): remove incorrect nullables, add `ApplicationEmoji#available` (#10913) * types: remove unintended nullables from app and base guild emojis * feat: add ApplicationEmoji#available * types(BaseGuildEmoji): fix incorrect JSDoc type for BaseGuildEmoji#name Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * types(Emoji): switch from # to . for property deprecation links Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * fix: remove default nulls in app emoji constructor on non-nullables * types(Emoji): replace raw data type pre 78d512c * types(Emoji): switch to ImageURLOptions for imageURL() Re-applies changes from #10613 Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * types(Emoji): remove deprecated `url` props types and descriptions Added by mistake in PR that used to target v14 Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * refactor(Emoji): wording and formatting changes to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * refactor(Emoji): missed wording and formatting change to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * fix(Emoji)!: remove non present Emoji#url from typings * fix(Emoji): re-apply emoji url types from 2c35084 --------- Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/structures/ApplicationEmoji.js | 81 +++++++++++++++---- .../src/structures/BaseGuildEmoji.js | 36 +++++++++ packages/discord.js/typings/index.d.ts | 18 +++-- 3 files changed, 114 insertions(+), 21 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 9d46db852..7e768c778 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -16,37 +16,42 @@ class ApplicationEmoji extends Emoji { */ this.application = application; - /** - * The user who created this emoji - * @type {?User} - */ - this.author = null; - - this.managed = null; - this.requiresColons = null; - this._patch(data); } _patch(data) { if ('name' in data) this.name = data.name; - if (data.user) this.author = this.client.users._add(data.user); + if (data.user) { + /** + * The user who created this emoji + * @type {User} + */ + this.author = this.client.users._add(data.user); + } if ('managed' in data) { /** - * Whether this emoji is managed by an external service - * @type {?boolean} + * Whether this emoji is managed by an external service. Always `false` for application emojis + * @type {false} */ this.managed = data.managed; } if ('require_colons' in data) { /** - * Whether or not this emoji requires colons surrounding it - * @type {?boolean} + * Whether this emoji requires colons surrounding it. Always `true` for application emojis + * @type {true} */ this.requiresColons = data.require_colons; } + + if ('available' in data) { + /** + * Whether this emoji is available. Always `true` for application emojis + * @type {true} + */ + this.available = data.available; + } } /** @@ -107,7 +112,8 @@ class ApplicationEmoji extends Emoji { other.id === this.id && other.name === this.name && other.managed === this.managed && - other.requiresColons === this.requiresColons + other.requiresColons === this.requiresColons && + other.available === this.available ); } @@ -115,4 +121,49 @@ class ApplicationEmoji extends Emoji { } } +/** + * The emoji's name + * @name name + * @memberof ApplicationEmoji + * @instance + * @type {string} + * @readonly + */ + +/** + * Whether the emoji is animated + * @name animated + * @memberof ApplicationEmoji + * @instance + * @type {boolean} + * @readonly + */ + +/** + * Returns a URL for the emoji. + * @method imageURL + * @memberof ApplicationEmoji + * @instance + * @param {EmojiURLOptions} [options] Options for the image URL + * @returns {string} + */ + +/** + * The time the emoji was created at + * @name createdAt + * @memberof ApplicationEmoji + * @instance + * @type {Date} + * @readonly + */ + +/** + * The timestamp the emoji was created at + * @name createdTimestamp + * @memberof ApplicationEmoji + * @instance + * @type {number} + * @readonly + */ + exports.ApplicationEmoji = ApplicationEmoji; diff --git a/packages/discord.js/src/structures/BaseGuildEmoji.js b/packages/discord.js/src/structures/BaseGuildEmoji.js index 485ff76fc..b811bf79a 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -62,4 +62,40 @@ class BaseGuildEmoji extends Emoji { * @returns {string} */ +/** + * The emoji's name + * @name name + * @memberof BaseGuildEmoji + * @instance + * @type {string} + * @readonly + */ + +/** + * Whether or not the emoji is animated + * @name animated + * @memberof BaseGuildEmoji + * @instance + * @type {boolean} + * @readonly + */ + +/** + * The time the emoji was created at. + * @name createdAt + * @memberof BaseGuildEmoji + * @instance + * @type {Date} + * @readonly + */ + +/** + * The timestamp the emoji was created at. + * @name createdTimestamp + * @memberof BaseGuildEmoji + * @instance + * @type {number} + * @readonly + */ + exports.BaseGuildEmoji = BaseGuildEmoji; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 4636362b3..7f23cb4e1 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -591,13 +591,14 @@ export abstract class BaseGuild extends Base { export class BaseGuildEmoji extends Emoji { protected constructor(client: Client, data: APIEmoji, guild: Guild | GuildPreview); public imageURL(options?: EmojiURLOptions): string; - public get url(): string; public available: boolean | null; public get createdAt(): Date; public get createdTimestamp(): number; public guild: Guild | GuildPreview; public id: Snowflake; - public managed: boolean | null; + public name: string; + public animated: boolean; + public managed: boolean; public requiresColons: boolean | null; } @@ -1268,7 +1269,6 @@ export class Emoji extends Base { public name: string | null; public get identifier(): string; public imageURL(options?: EmojiURLOptions): string | null; - public get url(): string | null; public toJSON(): unknown; public toString(): string; } @@ -1286,10 +1286,16 @@ export class ApplicationEmoji extends Emoji { private constructor(client: Client, data: APIEmoji, application: ClientApplication); public application: ClientApplication; - public author: User | null; + public author: User; public id: Snowflake; - public managed: boolean | null; - public requiresColons: boolean | null; + public managed: false; + public requiresColons: true; + public name: string; + public animated: boolean; + public available: true; + public get createdAt(): Date; + public get createdTimestamp(): number; + public imageURL(options?: EmojiURLOptions): string; public delete(): Promise; public edit(options: ApplicationEmojiEditOptions): Promise; public equals(other: ApplicationEmoji | unknown): boolean;