Skip to content

Commit

Permalink
feat(scheduledevent): add support for event cover images (#7337)
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Jan 26, 2022
1 parent e4bd07b commit 355f579
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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
* @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

0 comments on commit 355f579

Please sign in to comment.