From ea37cffdf452e1843a8f88025642b3ecfb2420c8 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Wed, 26 Jan 2022 15:47:47 -0500 Subject: [PATCH 1/2] feat(scheduledevent): add support for event cover images (#7337) --- src/structures/GuildScheduledEvent.js | 15 +++++++++++++++ typings/index.d.ts | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/structures/GuildScheduledEvent.js b/src/structures/GuildScheduledEvent.js index ff862b87cf44..64522d000d8f 100644 --- a/src/structures/GuildScheduledEvent.js +++ b/src/structures/GuildScheduledEvent.js @@ -156,6 +156,21 @@ class GuildScheduledEvent extends Base { } else { this.entityMetadata ??= null; } + + /** + * The cover image hash for this scheduled event + * @type {?string} + */ + this.image = data.image ?? null; + } + + /** + * The URL of this scheduled event's cover image + * @param {BaseImageURLOptions} [options={}] Options for image URL + * @returns {?string} + */ + coverImageURL(options = {}) { + return this.image && this.client.rest.cdn.guildScheduledEventCover(this.id, this.image, options); } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 9a8f4fa413e3..35987b86304c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1187,6 +1187,8 @@ export class GuildScheduledEvent): string | null; public createInviteURL(options?: CreateGuildScheduledEventInviteURLOptions): Promise; public edit>( options: GuildScheduledEventEditOptions, From 4308d5130b628433896ccdc9487225c18cb98a80 Mon Sep 17 00:00:00 2001 From: Ben <88249114+BenjammingKirby@users.noreply.github.com> Date: Sun, 6 Mar 2022 12:13:08 -0600 Subject: [PATCH 2/2] feat(scheduledevent): event cover images v13 --- src/structures/GuildScheduledEvent.js | 6 +++--- src/util/Constants.js | 2 ++ typings/index.d.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/structures/GuildScheduledEvent.js b/src/structures/GuildScheduledEvent.js index 64522d000d8f..263a7de58a0a 100644 --- a/src/structures/GuildScheduledEvent.js +++ b/src/structures/GuildScheduledEvent.js @@ -166,11 +166,11 @@ class GuildScheduledEvent extends Base { /** * The URL of this scheduled event's cover image - * @param {BaseImageURLOptions} [options={}] Options for image URL + * @param {StaticImageURLOptions} [options={}] Options for image URL * @returns {?string} */ - coverImageURL(options = {}) { - return this.image && this.client.rest.cdn.guildScheduledEventCover(this.id, this.image, options); + coverImageURL({ format, size } = {}) { + return this.image && this.client.rest.cdn.guildScheduledEventCover(this.id, this.image, format, size); } /** diff --git a/src/util/Constants.js b/src/util/Constants.js index 14b0e526c906..c09af5d23928 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -77,6 +77,8 @@ exports.Endpoints = { `${root}/stickers/${stickerId}.${stickerFormat === 'LOTTIE' ? 'json' : 'png'}`, RoleIcon: (roleId, hash, format = 'webp', size) => makeImageUrl(`${root}/role-icons/${roleId}/${hash}`, { size, format }), + guildScheduledEventCover: (scheduledEventId, coverHash, format, size) => + makeImageUrl(`${root}/guild-events/${scheduledEventId}/${coverHash}`, { size, format }), }; }, invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`), diff --git a/typings/index.d.ts b/typings/index.d.ts index 35987b86304c..9ce2bb730a6f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1188,7 +1188,7 @@ export class GuildScheduledEvent): string | null; + public coverImageURL(options?: StaticImageURLOptions): string | null; public createInviteURL(options?: CreateGuildScheduledEventInviteURLOptions): Promise; public edit>( options: GuildScheduledEventEditOptions,