mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
feat(Guild): discovery splash (#4619)
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
@@ -131,11 +131,17 @@ class Guild extends Base {
|
|||||||
this.icon = data.icon;
|
this.icon = data.icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hash of the guild splash image (VIP only)
|
* The hash of the guild invite splash image
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.splash = data.splash;
|
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
|
* The region the guild is located in
|
||||||
* @type {string}
|
* @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
|
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
||||||
* @returns {?string}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
@@ -514,6 +520,16 @@ class Guild extends Base {
|
|||||||
return this.client.rest.cdn.Splash(this.id, this.splash, format, size);
|
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
|
* The owner of the guild
|
||||||
* @type {?GuildMember}
|
* @type {?GuildMember}
|
||||||
@@ -975,7 +991,8 @@ class Guild extends Base {
|
|||||||
* @property {number} [afkTimeout] The AFK timeout of the guild
|
* @property {number} [afkTimeout] The AFK timeout of the guild
|
||||||
* @property {Base64Resolvable} [icon] The icon of the guild
|
* @property {Base64Resolvable} [icon] The icon of the guild
|
||||||
* @property {GuildMemberResolvable} [owner] The owner 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 {Base64Resolvable} [banner] The banner of the guild
|
||||||
* @property {DefaultMessageNotifications|number} [defaultMessageNotifications] The default message notifications
|
* @property {DefaultMessageNotifications|number} [defaultMessageNotifications] The default message notifications
|
||||||
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
|
* @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 (typeof data.icon !== 'undefined') _data.icon = data.icon;
|
||||||
if (data.owner) _data.owner_id = this.client.users.resolveID(data.owner);
|
if (data.owner) _data.owner_id = this.client.users.resolveID(data.owner);
|
||||||
if (data.splash) _data.splash = data.splash;
|
if (data.splash) _data.splash = data.splash;
|
||||||
|
if (data.discoverySplash) _data.discovery_splash = data.discoverySplash;
|
||||||
if (data.banner) _data.banner = data.banner;
|
if (data.banner) _data.banner = data.banner;
|
||||||
if (typeof data.explicitContentFilter !== 'undefined') {
|
if (typeof data.explicitContentFilter !== 'undefined') {
|
||||||
_data.explicit_content_filter =
|
_data.explicit_content_filter =
|
||||||
@@ -1190,9 +1208,9 @@ class Guild extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new guild splash screen.
|
* Sets a new guild invite splash image.
|
||||||
* @param {Base64Resolvable|BufferResolvable} splash The new splash screen of the guild
|
* @param {Base64Resolvable|BufferResolvable} splash The new invite splash image of the guild
|
||||||
* @param {string} [reason] Reason for changing the guild's splash screen
|
* @param {string} [reason] Reason for changing the guild's invite splash image
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
* // Edit the guild splash
|
* // Edit the guild splash
|
||||||
@@ -1204,6 +1222,21 @@ class Guild extends Base {
|
|||||||
return this.edit({ splash: await DataResolver.resolveImage(splash), reason });
|
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.
|
* Sets a new guild banner.
|
||||||
* @param {Base64Resolvable|BufferResolvable} banner The new banner of the guild
|
* @param {Base64Resolvable|BufferResolvable} banner The new banner of the guild
|
||||||
@@ -1377,6 +1410,7 @@ class Guild extends Base {
|
|||||||
this.id === guild.id &&
|
this.id === guild.id &&
|
||||||
this.available === guild.available &&
|
this.available === guild.available &&
|
||||||
this.splash === guild.splash &&
|
this.splash === guild.splash &&
|
||||||
|
this.discoverySplash === guild.discoverySplash &&
|
||||||
this.region === guild.region &&
|
this.region === guild.region &&
|
||||||
this.name === guild.name &&
|
this.name === guild.name &&
|
||||||
this.memberCount === guild.memberCount &&
|
this.memberCount === guild.memberCount &&
|
||||||
@@ -1421,6 +1455,7 @@ class Guild extends Base {
|
|||||||
});
|
});
|
||||||
json.iconURL = this.iconURL();
|
json.iconURL = this.iconURL();
|
||||||
json.splashURL = this.splashURL();
|
json.splashURL = this.splashURL();
|
||||||
|
json.discoverySplashURL = this.discoverySplashURL();
|
||||||
json.bannerURL = this.bannerURL();
|
json.bannerURL = this.bannerURL();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@@ -618,6 +618,7 @@ declare module 'discord.js' {
|
|||||||
public defaultMessageNotifications: DefaultMessageNotifications | number;
|
public defaultMessageNotifications: DefaultMessageNotifications | number;
|
||||||
public deleted: boolean;
|
public deleted: boolean;
|
||||||
public description: string | null;
|
public description: string | null;
|
||||||
|
public discoverySplash: string | null;
|
||||||
public embedChannel: GuildChannel | null;
|
public embedChannel: GuildChannel | null;
|
||||||
public embedChannelID: Snowflake | null;
|
public embedChannelID: Snowflake | null;
|
||||||
public embedEnabled: boolean;
|
public embedEnabled: boolean;
|
||||||
@@ -668,6 +669,7 @@ declare module 'discord.js' {
|
|||||||
public bannerURL(options?: ImageURLOptions): string | null;
|
public bannerURL(options?: ImageURLOptions): string | null;
|
||||||
public createIntegration(data: IntegrationData, reason?: string): Promise<Guild>;
|
public createIntegration(data: IntegrationData, reason?: string): Promise<Guild>;
|
||||||
public delete(): Promise<Guild>;
|
public delete(): Promise<Guild>;
|
||||||
|
public discoverySplashURL(options?: ImageURLOptions): string | null;
|
||||||
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
||||||
public equals(guild: Guild): boolean;
|
public equals(guild: Guild): boolean;
|
||||||
public fetch(): Promise<Guild>;
|
public fetch(): Promise<Guild>;
|
||||||
@@ -694,6 +696,7 @@ declare module 'discord.js' {
|
|||||||
defaultMessageNotifications: DefaultMessageNotifications | number,
|
defaultMessageNotifications: DefaultMessageNotifications | number,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<Guild>;
|
): Promise<Guild>;
|
||||||
|
public setDiscoverySplash(discoverySplash: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setEmbed(embed: GuildWidgetData, reason?: string): Promise<Guild>;
|
public setEmbed(embed: GuildWidgetData, reason?: string): Promise<Guild>;
|
||||||
public setExplicitContentFilter(explicitContentFilter: ExplicitContentFilterLevel, reason?: string): Promise<Guild>;
|
public setExplicitContentFilter(explicitContentFilter: ExplicitContentFilterLevel, reason?: string): Promise<Guild>;
|
||||||
public setIcon(icon: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
public setIcon(icon: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||||
@@ -2539,6 +2542,7 @@ declare module 'discord.js' {
|
|||||||
icon?: Base64Resolvable;
|
icon?: Base64Resolvable;
|
||||||
owner?: GuildMemberResolvable;
|
owner?: GuildMemberResolvable;
|
||||||
splash?: Base64Resolvable;
|
splash?: Base64Resolvable;
|
||||||
|
discoverySplash?: Base64Resolvable;
|
||||||
banner?: Base64Resolvable;
|
banner?: Base64Resolvable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user