From a7535a2232c4de4553d0d2a2cee315124e1bdfaa Mon Sep 17 00:00:00 2001 From: Ben <88249114+BenjammingKirby@users.noreply.github.com> Date: Mon, 7 Mar 2022 12:26:57 -0600 Subject: [PATCH] feat(scheduledevents): Event cover images for v13 (#7613) Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> --- src/structures/GuildScheduledEvent.js | 15 +++++++++++++++ src/util/Constants.js | 2 ++ typings/index.d.ts | 2 ++ 3 files changed, 19 insertions(+) diff --git a/src/structures/GuildScheduledEvent.js b/src/structures/GuildScheduledEvent.js index ff862b87cf44..263a7de58a0a 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 {StaticImageURLOptions} [options={}] Options for image URL + * @returns {?string} + */ + 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 9a8f4fa413e3..9ce2bb730a6f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1187,6 +1187,8 @@ export class GuildScheduledEvent; public edit>( options: GuildScheduledEventEditOptions,