From b38564d63c1775c90e4ecaea407c15581293075f Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Mon, 26 May 2025 12:59:16 -0500 Subject: [PATCH 01/12] types: remove unintended nullables from app and base guild emojis --- .../src/structures/ApplicationEmoji.js | 65 +++++++++++++++++-- .../src/structures/BaseGuildEmoji.js | 46 +++++++++++++ packages/discord.js/typings/index.d.ts | 22 +++++-- 3 files changed, 122 insertions(+), 11 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 9d46db85210e..9195d1e2b588 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -18,7 +18,7 @@ class ApplicationEmoji extends Emoji { /** * The user who created this emoji - * @type {?User} + * @type {User} */ this.author = null; @@ -34,16 +34,16 @@ class ApplicationEmoji extends Emoji { 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 or not this emoji requires colons surrounding it. Always true for application emojis + * @type {true} */ this.requiresColons = data.require_colons; } @@ -115,4 +115,59 @@ class ApplicationEmoji extends Emoji { } } +/** + * The emoji's name + * @name name + * @memberof ApplicationEmoji + * @instance + * @type {string} + * @readonly + */ + +/** + * Whether or not the emoji is animated + * @name animated + * @memberof ApplicationEmoji + * @instance + * @type {boolean} + * @readonly + */ + +/** + * Returns a URL for the emoji. + * @method imageURL + * @memberof ApplicationEmoji + * @instance + * @param {BaseImageURLOptions} [options] Options for the image URL + * @returns {string} + */ + +/** + * Returns a URL for the emoji. + * @name url + * @memberof ApplicationEmoji + * @instance + * @type {string} + * @readonly + * @deprecated Use {@link ApplicationEmoji#imageURL} instead. + */ + +/** + * 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 bb4e8d005e2e..c696048299fe 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -62,4 +62,50 @@ class BaseGuildEmoji extends Emoji { * @returns {string} */ +/** + * Returns a URL for the emoji. + * @name url + * @memberof BaseGuildEmoji + * @instance + * @type {string} + * @readonly + * @deprecated Use {@link BaseGuildEmoji#imageURL} instead. + */ + +/** + * The emoji's name + * @name name + * @memberof BaseGuildEmoji + * @instance + * @type {Snowflake} + * @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 d22d659306cb..e945ae22d43f 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -589,15 +589,18 @@ export abstract class BaseGuild extends Base { } export class BaseGuildEmoji extends Emoji { - protected constructor(client: Client, data: APIEmoji, guild: Guild | GuildPreview); - public imageURL(options?: ImageURLOptions): string; + protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); + public imageURL(options?: BaseImageURLOptions): string; + /** @deprecated Use {@link BaseGuildEmoji#imageURL} instead */ 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; } @@ -1286,10 +1289,17 @@ 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 get createdAt(): Date; + public get createdTimestamp(): number; + /** @deprecated Use {@link ApplicationEmoji#imageURL} instead */ + public get url(): string; + public imageURL(options?: BaseImageURLOptions): string; public delete(): Promise; public edit(options: ApplicationEmojiEditOptions): Promise; public equals(other: ApplicationEmoji | unknown): boolean; From 1559ab6d5c90fbf9f0aae43b6639d8f6d55c9405 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Sun, 25 May 2025 16:55:34 -0500 Subject: [PATCH 02/12] feat: add ApplicationEmoji#available --- .../discord.js/src/structures/ApplicationEmoji.js | 13 ++++++++++++- packages/discord.js/typings/index.d.ts | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 9195d1e2b588..565491b42c9d 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -24,6 +24,7 @@ class ApplicationEmoji extends Emoji { this.managed = null; this.requiresColons = null; + this.available = null; this._patch(data); } @@ -47,6 +48,15 @@ class ApplicationEmoji extends Emoji { */ this.requiresColons = data.require_colons; } + + if ('available' in data) { + /** + * Whether this emoji is available + * @remarks Always true for application emojis + * @type {true} + */ + this.available = data.available; + } } /** @@ -107,7 +117,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 ); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index e945ae22d43f..ebe9084f1035 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1295,6 +1295,7 @@ export class ApplicationEmoji extends Emoji { public requiresColons: true; public name: string; public animated: boolean; + public available: true; public get createdAt(): Date; public get createdTimestamp(): number; /** @deprecated Use {@link ApplicationEmoji#imageURL} instead */ From f609e98381aaaf83a8ec59226518292a5a79bb37 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Mon, 26 May 2025 10:00:58 -0500 Subject: [PATCH 03/12] types(BaseGuildEmoji): fix incorrect JSDoc type for BaseGuildEmoji#name Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> --- packages/discord.js/src/structures/BaseGuildEmoji.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/BaseGuildEmoji.js b/packages/discord.js/src/structures/BaseGuildEmoji.js index c696048299fe..5b805c76ac08 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -77,7 +77,7 @@ class BaseGuildEmoji extends Emoji { * @name name * @memberof BaseGuildEmoji * @instance - * @type {Snowflake} + * @type {string} * @readonly */ From ac20dd21b817a9763ca0b712a28cf003d6841617 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Mon, 26 May 2025 10:11:42 -0500 Subject: [PATCH 04/12] types(Emoji): switch from # to . for property deprecation links Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> --- packages/discord.js/typings/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index ebe9084f1035..032945534a1a 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -591,7 +591,7 @@ export abstract class BaseGuild extends Base { export class BaseGuildEmoji extends Emoji { protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); public imageURL(options?: BaseImageURLOptions): string; - /** @deprecated Use {@link BaseGuildEmoji#imageURL} instead */ + /** @deprecated Use {@link BaseGuildEmoji.imageURL} instead */ public get url(): string; public available: boolean | null; public get createdAt(): Date; @@ -1298,7 +1298,7 @@ export class ApplicationEmoji extends Emoji { public available: true; public get createdAt(): Date; public get createdTimestamp(): number; - /** @deprecated Use {@link ApplicationEmoji#imageURL} instead */ + /** @deprecated Use {@link ApplicationEmoji.imageURL} instead */ public get url(): string; public imageURL(options?: BaseImageURLOptions): string; public delete(): Promise; From efa0f17a8ec7f8edb7b669fe4838fd435f3afc16 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Mon, 26 May 2025 13:57:39 -0500 Subject: [PATCH 05/12] fix: remove default nulls in app emoji constructor on non-nullables --- .../src/structures/ApplicationEmoji.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 565491b42c9d..8dd04cfcdf67 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -16,22 +16,18 @@ 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.available = 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) { /** @@ -51,8 +47,7 @@ class ApplicationEmoji extends Emoji { if ('available' in data) { /** - * Whether this emoji is available - * @remarks Always true for application emojis + * Whether this emoji is available. Always true for application emojis * @type {true} */ this.available = data.available; From 2c5bdb7461452b6b3762dc994b36ec7dedbf1bf5 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Mon, 26 May 2025 14:06:30 -0500 Subject: [PATCH 06/12] types(Emoji): replace raw data type pre 78d512c --- packages/discord.js/typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 032945534a1a..d282c9282e50 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -589,7 +589,7 @@ export abstract class BaseGuild extends Base { } export class BaseGuildEmoji extends Emoji { - protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); + protected constructor(client: Client, data: APIEmoji, guild: Guild | GuildPreview); public imageURL(options?: BaseImageURLOptions): string; /** @deprecated Use {@link BaseGuildEmoji.imageURL} instead */ public get url(): string; From d475f2ead70b5c705570172f8c6e7ce7db4debd7 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Mon, 26 May 2025 16:31:56 -0500 Subject: [PATCH 07/12] types(Emoji): switch to ImageURLOptions for imageURL() Re-applies changes from #10613 Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> --- packages/discord.js/src/structures/ApplicationEmoji.js | 2 +- packages/discord.js/typings/index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 8dd04cfcdf67..2ea8e8998c29 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -144,7 +144,7 @@ class ApplicationEmoji extends Emoji { * @method imageURL * @memberof ApplicationEmoji * @instance - * @param {BaseImageURLOptions} [options] Options for the image URL + * @param {ImageURLOptions} [options] Options for the image URL * @returns {string} */ diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index d282c9282e50..0c96a68096e7 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -590,7 +590,7 @@ export abstract class BaseGuild extends Base { export class BaseGuildEmoji extends Emoji { protected constructor(client: Client, data: APIEmoji, guild: Guild | GuildPreview); - public imageURL(options?: BaseImageURLOptions): string; + public imageURL(options?: ImageURLOptions): string; /** @deprecated Use {@link BaseGuildEmoji.imageURL} instead */ public get url(): string; public available: boolean | null; @@ -1300,7 +1300,7 @@ export class ApplicationEmoji extends Emoji { public get createdTimestamp(): number; /** @deprecated Use {@link ApplicationEmoji.imageURL} instead */ public get url(): string; - public imageURL(options?: BaseImageURLOptions): string; + public imageURL(options?: ImageURLOptions): string; public delete(): Promise; public edit(options: ApplicationEmojiEditOptions): Promise; public equals(other: ApplicationEmoji | unknown): boolean; From 7922c3907b17672f6f61fd5ce7f0fdbbfa87d186 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Tue, 27 May 2025 10:01:34 -0500 Subject: [PATCH 08/12] 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> --- packages/discord.js/src/structures/ApplicationEmoji.js | 10 ---------- packages/discord.js/src/structures/BaseGuildEmoji.js | 10 ---------- packages/discord.js/typings/index.d.ts | 4 ---- 3 files changed, 24 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 2ea8e8998c29..501aa912d3cb 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -148,16 +148,6 @@ class ApplicationEmoji extends Emoji { * @returns {string} */ -/** - * Returns a URL for the emoji. - * @name url - * @memberof ApplicationEmoji - * @instance - * @type {string} - * @readonly - * @deprecated Use {@link ApplicationEmoji#imageURL} instead. - */ - /** * The time the emoji was created at * @name createdAt diff --git a/packages/discord.js/src/structures/BaseGuildEmoji.js b/packages/discord.js/src/structures/BaseGuildEmoji.js index 5b805c76ac08..a9837c3814a0 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -62,16 +62,6 @@ class BaseGuildEmoji extends Emoji { * @returns {string} */ -/** - * Returns a URL for the emoji. - * @name url - * @memberof BaseGuildEmoji - * @instance - * @type {string} - * @readonly - * @deprecated Use {@link BaseGuildEmoji#imageURL} instead. - */ - /** * The emoji's name * @name name diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 0c96a68096e7..7e3345524a57 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -591,8 +591,6 @@ export abstract class BaseGuild extends Base { export class BaseGuildEmoji extends Emoji { protected constructor(client: Client, data: APIEmoji, guild: Guild | GuildPreview); public imageURL(options?: ImageURLOptions): string; - /** @deprecated Use {@link BaseGuildEmoji.imageURL} instead */ - public get url(): string; public available: boolean | null; public get createdAt(): Date; public get createdTimestamp(): number; @@ -1298,8 +1296,6 @@ export class ApplicationEmoji extends Emoji { public available: true; public get createdAt(): Date; public get createdTimestamp(): number; - /** @deprecated Use {@link ApplicationEmoji.imageURL} instead */ - public get url(): string; public imageURL(options?: ImageURLOptions): string; public delete(): Promise; public edit(options: ApplicationEmojiEditOptions): Promise; From b27eedc5492ae44a86b5f1cc33251f3c846904e4 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Tue, 27 May 2025 10:02:17 -0500 Subject: [PATCH 09/12] refactor(Emoji): wording and formatting changes to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/discord.js/src/structures/ApplicationEmoji.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 501aa912d3cb..bbcddcf6c5e4 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -31,7 +31,7 @@ class ApplicationEmoji extends Emoji { if ('managed' in data) { /** - * Whether this emoji is managed by an external service. Always false for application emojis + * Whether this emoji is managed by an external service. Always `false` for application emojis * @type {false} */ this.managed = data.managed; @@ -39,7 +39,7 @@ class ApplicationEmoji extends Emoji { if ('require_colons' in data) { /** - * Whether or not this emoji requires colons surrounding it. Always true for application emojis + * Whether this emoji requires colons surrounding it. Always `true` for application emojis * @type {true} */ this.requiresColons = data.require_colons; @@ -131,7 +131,7 @@ class ApplicationEmoji extends Emoji { */ /** - * Whether or not the emoji is animated + * Whether the emoji is animated * @name animated * @memberof ApplicationEmoji * @instance From 18ffa9157e9fb63a6787d3945a4e05db5f5ceb63 Mon Sep 17 00:00:00 2001 From: Amgelo563 <61554601+Amgelo563@users.noreply.github.com> Date: Tue, 27 May 2025 10:03:02 -0500 Subject: [PATCH 10/12] refactor(Emoji): missed wording and formatting change to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/discord.js/src/structures/ApplicationEmoji.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index bbcddcf6c5e4..d09e5734fcaa 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -47,7 +47,7 @@ class ApplicationEmoji extends Emoji { if ('available' in data) { /** - * Whether this emoji is available. Always true for application emojis + * Whether this emoji is available. Always `true` for application emojis * @type {true} */ this.available = data.available; From b06ccccbb25f7068d94cdf0980c18b854bad72b9 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Wed, 28 May 2025 14:52:37 -0500 Subject: [PATCH 11/12] fix(Emoji)!: remove non present Emoji#url from typings --- packages/discord.js/typings/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 535d983d6e53..4a6e431818be 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1269,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; } From de4e14732aee5d94c4681e657689aead67243be2 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Wed, 28 May 2025 14:56:06 -0500 Subject: [PATCH 12/12] fix(Emoji): re-apply emoji url types from 2c35084 --- packages/discord.js/src/structures/ApplicationEmoji.js | 2 +- packages/discord.js/typings/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index d09e5734fcaa..7e768c778b1d 100644 --- a/packages/discord.js/src/structures/ApplicationEmoji.js +++ b/packages/discord.js/src/structures/ApplicationEmoji.js @@ -144,7 +144,7 @@ class ApplicationEmoji extends Emoji { * @method imageURL * @memberof ApplicationEmoji * @instance - * @param {ImageURLOptions} [options] Options for the image URL + * @param {EmojiURLOptions} [options] Options for the image URL * @returns {string} */ diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 4a6e431818be..7f23cb4e1b53 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1295,7 +1295,7 @@ export class ApplicationEmoji extends Emoji { public available: true; public get createdAt(): Date; public get createdTimestamp(): number; - public imageURL(options?: ImageURLOptions): string; + public imageURL(options?: EmojiURLOptions): string; public delete(): Promise; public edit(options: ApplicationEmojiEditOptions): Promise; public equals(other: ApplicationEmoji | unknown): boolean;