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(scheduledevent): add support for event cover images #7337

Merged
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
5 changes: 5 additions & 0 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,8 @@ module.exports = Client;
* @external ImageURLOptions
* @see {@link https://discord.js.org/#/docs/rest/main/typedef/ImageURLOptions}
*/

/**
* @external BaseImageURLOptions
* @see {@link https://discord.js.org/#/docs/rest/main/typedef/BaseImageURLOptions}
*/
15 changes: 15 additions & 0 deletions packages/discord.js/src/structures/GuildScheduledEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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
suneettipirneni marked this conversation as resolved.
Show resolved Hide resolved
* @returns {?string}
*/
coverImageURL(options = {}) {
return this.image && this.client.rest.cdn.guildScheduledEventCover(this.id, this.image, options);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
userMention,
} from '@discordjs/builders';
import { Collection } from '@discordjs/collection';
import { ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
import {
APIActionRowComponent,
APIApplicationCommand,
Expand Down Expand Up @@ -1160,6 +1160,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?: Readonly<BaseImageURLOptions>): string | null;
public createInviteURL(options?: CreateGuildScheduledEventInviteURLOptions): Promise<string>;
public edit<T extends GuildScheduledEventSetStatusArg<S>>(
options: GuildScheduledEventEditOptions<S, T>,
Expand Down