feat(Guild): discovery splash (#4619)

Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Advaith
2020-08-12 02:09:18 -07:00
committed by GitHub
parent 446bbfe9eb
commit 5be6630843
2 changed files with 45 additions and 6 deletions

View File

@@ -131,11 +131,17 @@ class Guild extends Base {
this.icon = data.icon;
/**
* The hash of the guild splash image (VIP only)
* The hash of the guild invite splash image
* @type {?string}
*/
this.splash = data.splash;
/**
* The hash of the guild discovery splash image
* @type {?string}
*/
this.discoverySplash = data.discovery_splash;
/**
* The region the guild is located in
* @type {string}
@@ -505,7 +511,7 @@ class Guild extends Base {
}
/**
* The URL to this guild's splash.
* The URL to this guild's invite splash image.
* @param {ImageURLOptions} [options={}] Options for the Image URL
* @returns {?string}
*/
@@ -514,6 +520,16 @@ class Guild extends Base {
return this.client.rest.cdn.Splash(this.id, this.splash, format, size);
}
/**
* The URL to this guild's discovery splash image.
* @param {ImageURLOptions} [options={}] Options for the Image URL
* @returns {?string}
*/
discoverySplashURL({ format, size } = {}) {
if (!this.discoverySplash) return null;
return this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size);
}
/**
* The owner of the guild
* @type {?GuildMember}
@@ -975,7 +991,8 @@ class Guild extends Base {
* @property {number} [afkTimeout] The AFK timeout of the guild
* @property {Base64Resolvable} [icon] The icon of the guild
* @property {GuildMemberResolvable} [owner] The owner of the guild
* @property {Base64Resolvable} [splash] The splash screen of the guild
* @property {Base64Resolvable} [splash] The invite splash image of the guild
* @property {Base64Resolvable} [discoverySplash] The discovery splash image of the guild
* @property {Base64Resolvable} [banner] The banner of the guild
* @property {DefaultMessageNotifications|number} [defaultMessageNotifications] The default message notifications
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
@@ -1015,6 +1032,7 @@ class Guild extends Base {
if (typeof data.icon !== 'undefined') _data.icon = data.icon;
if (data.owner) _data.owner_id = this.client.users.resolveID(data.owner);
if (data.splash) _data.splash = data.splash;
if (data.discoverySplash) _data.discovery_splash = data.discoverySplash;
if (data.banner) _data.banner = data.banner;
if (typeof data.explicitContentFilter !== 'undefined') {
_data.explicit_content_filter =
@@ -1190,9 +1208,9 @@ class Guild extends Base {
}
/**
* Sets a new guild splash screen.
* @param {Base64Resolvable|BufferResolvable} splash The new splash screen of the guild
* @param {string} [reason] Reason for changing the guild's splash screen
* Sets a new guild invite splash image.
* @param {Base64Resolvable|BufferResolvable} splash The new invite splash image of the guild
* @param {string} [reason] Reason for changing the guild's invite splash image
* @returns {Promise<Guild>}
* @example
* // Edit the guild splash
@@ -1204,6 +1222,21 @@ class Guild extends Base {
return this.edit({ splash: await DataResolver.resolveImage(splash), reason });
}
/**
* Sets a new guild discovery splash image.
* @param {Base64Resolvable|BufferResolvable} discoverySplash The new discovery splash image of the guild
* @param {string} [reason] Reason for changing the guild's discovery splash image
* @returns {Promise<Guild>}
* @example
* // Edit the guild discovery splash
* guild.setDiscoverySplash('./discoverysplash.png')
* .then(updated => console.log('Updated the guild discovery splash'))
* .catch(console.error);
*/
async setDiscoverySplash(discoverySplash, reason) {
return this.edit({ discoverySplash: await DataResolver.resolveImage(discoverySplash), reason });
}
/**
* Sets a new guild banner.
* @param {Base64Resolvable|BufferResolvable} banner The new banner of the guild
@@ -1377,6 +1410,7 @@ class Guild extends Base {
this.id === guild.id &&
this.available === guild.available &&
this.splash === guild.splash &&
this.discoverySplash === guild.discoverySplash &&
this.region === guild.region &&
this.name === guild.name &&
this.memberCount === guild.memberCount &&
@@ -1421,6 +1455,7 @@ class Guild extends Base {
});
json.iconURL = this.iconURL();
json.splashURL = this.splashURL();
json.discoverySplashURL = this.discoverySplashURL();
json.bannerURL = this.bannerURL();
return json;
}

4
typings/index.d.ts vendored
View File

@@ -618,6 +618,7 @@ declare module 'discord.js' {
public defaultMessageNotifications: DefaultMessageNotifications | number;
public deleted: boolean;
public description: string | null;
public discoverySplash: string | null;
public embedChannel: GuildChannel | null;
public embedChannelID: Snowflake | null;
public embedEnabled: boolean;
@@ -668,6 +669,7 @@ declare module 'discord.js' {
public bannerURL(options?: ImageURLOptions): string | null;
public createIntegration(data: IntegrationData, reason?: string): Promise<Guild>;
public delete(): Promise<Guild>;
public discoverySplashURL(options?: ImageURLOptions): string | null;
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
public equals(guild: Guild): boolean;
public fetch(): Promise<Guild>;
@@ -694,6 +696,7 @@ declare module 'discord.js' {
defaultMessageNotifications: DefaultMessageNotifications | number,
reason?: string,
): Promise<Guild>;
public setDiscoverySplash(discoverySplash: Base64Resolvable | null, reason?: string): Promise<Guild>;
public setEmbed(embed: GuildWidgetData, reason?: string): Promise<Guild>;
public setExplicitContentFilter(explicitContentFilter: ExplicitContentFilterLevel, reason?: string): Promise<Guild>;
public setIcon(icon: Base64Resolvable | null, reason?: string): Promise<Guild>;
@@ -2539,6 +2542,7 @@ declare module 'discord.js' {
icon?: Base64Resolvable;
owner?: GuildMemberResolvable;
splash?: Base64Resolvable;
discoverySplash?: Base64Resolvable;
banner?: Base64Resolvable;
}