From 8ccbc013dc1fbc06f88ab3710681d5cc20fdf014 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Sun, 25 May 2025 16:53:57 -0500 Subject: [PATCH 1/4] types: remove unintended nullables from app and base guild emojis --- .../src/structures/ApplicationEmoji.js | 63 ++++++++++++++++++- .../src/structures/BaseGuildEmoji.js | 36 +++++++++++ packages/discord.js/typings/index.d.ts | 18 ++++-- 3 files changed, 110 insertions(+), 7 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationEmoji.js b/packages/discord.js/src/structures/ApplicationEmoji.js index 1688c6512243..e5f084c5cb6d 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; @@ -35,7 +35,8 @@ class ApplicationEmoji extends Emoji { if ('managed' in data) { /** * Whether this emoji is managed by an external service - * @type {?boolean} + * @remarks Always false for application emojis + * @type {false} */ this.managed = data.managed; } @@ -43,7 +44,8 @@ class ApplicationEmoji extends Emoji { if ('require_colons' in data) { /** * Whether or not this emoji requires colons surrounding it - * @type {?boolean} + * @remarks Always true for application emojis + * @type {true} */ this.requiresColons = data.require_colons; } @@ -115,4 +117,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 + */ + module.exports = ApplicationEmoji; diff --git a/packages/discord.js/src/structures/BaseGuildEmoji.js b/packages/discord.js/src/structures/BaseGuildEmoji.js index a5c2d5da1bf8..a24653c4d816 100644 --- a/packages/discord.js/src/structures/BaseGuildEmoji.js +++ b/packages/discord.js/src/structures/BaseGuildEmoji.js @@ -72,4 +72,40 @@ class BaseGuildEmoji extends Emoji { * @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 + */ + module.exports = BaseGuildEmoji; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 659b73ad20f7..40fddb5ad954 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -704,13 +704,16 @@ 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 */ 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; } @@ -1490,10 +1493,17 @@ export class ApplicationEmoji extends Emoji { private constructor(client: Client, data: RawApplicationEmojiData, 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 f4887ad87ebcbde91a1a4dc095b8be01e9a1cb2a Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Sun, 25 May 2025 16:55:34 -0500 Subject: [PATCH 2/4] 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 e5f084c5cb6d..7fbd183d83a6 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); } @@ -49,6 +50,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; + } } /** @@ -109,7 +119,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 40fddb5ad954..05cc06509b52 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1499,6 +1499,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 9903aad1f35a52901e9a33f5587127d9ce3c3a25 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 3/4] 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 a24653c4d816..8e1c094afb79 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 fb6b2df6dde8e12233c2ac0ad09875f6547e1e91 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 4/4] 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 05cc06509b52..ee1e99fb2df4 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -704,7 +704,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; @@ -1502,7 +1502,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;