Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scheduledevents): Event cover images for v13 #7613

Merged
merged 2 commits into from Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/structures/GuildScheduledEvent.js
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/util/Constants.js
Expand Up @@ -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}`),
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Expand Up @@ -1187,6 +1187,8 @@ export class GuildScheduledEvent<S extends GuildScheduledEventStatus = GuildSche
public readonly channel: VoiceChannel | StageChannel | null;
public readonly guild: Guild | null;
public readonly url: string;
public readonly image: string | null;
public coverImageURL(options?: StaticImageURLOptions): string | null;
public createInviteURL(options?: CreateGuildScheduledEventInviteURLOptions): Promise<string>;
public edit<T extends GuildScheduledEventSetStatusArg<S>>(
options: GuildScheduledEventEditOptions<S, T>,
Expand Down