feat(scheduledevent): add support for event cover images (#7337)

This commit is contained in:
Suneet Tipirneni
2022-01-26 15:47:47 -05:00
committed by GitHub
parent e4bd07b239
commit 355f579771
3 changed files with 23 additions and 1 deletions

View File

@@ -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}
*/

View File

@@ -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);
}
/**

View File

@@ -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,
@@ -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>,