From 01826aeefe52a9314cedbd28ef1701b3c8fe5f5f Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 19 Jan 2020 13:07:09 +0100 Subject: [PATCH] feat(Guild): add setBanner method and banner to edit (#3708) --- src/structures/Guild.js | 12 ++++++++++++ typings/index.d.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index c1fbd70b9..b5de89454 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -851,6 +851,7 @@ class Guild { * @property {ChannelResolvable} [systemChannel] The system channel of the guild * @property {number} [afkTimeout] The AFK timeout of the guild * @property {Base64Resolvable} [icon] The icon of the guild + * @property {Base64Resolvable} [banner] The banner of the guild * @property {GuildMemberResolvable} [owner] The owner of the guild * @property {Base64Resolvable} [splash] The splash screen of the guild */ @@ -884,6 +885,7 @@ class Guild { if (typeof data.icon !== 'undefined') _data.icon = data.icon; if (data.owner) _data.owner_id = this.client.resolver.resolveUser(data.owner).id; if (typeof data.splash !== 'undefined') _data.splash = data.splash; + if (typeof data.banner !== 'undefined') _data.banner = data.banner; if (typeof data.explicitContentFilter !== 'undefined') { _data.explicit_content_filter = Number(data.explicitContentFilter); } @@ -895,6 +897,16 @@ class Guild { return this.client.rest.methods.updateGuild(this, _data, reason); } + /** + * Sets a new guild banner. + * @param {BufferResolvable|Base64Resolvable} banner The new banner of the guild + * @param {string} [reason] Reason for changing the guild's banner + * @returns {Guild} + */ + setBanner(banner, reason) { + return this.client.resolver.resolveImage(banner).then(data => this.edit({ banner: data }, reason)); + } + /** * Edit the level of the explicit content filter. * @param {number} explicitContentFilter The new level of the explicit content filter diff --git a/typings/index.d.ts b/typings/index.d.ts index b2536e72f..a7a612c77 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -570,6 +570,7 @@ declare module 'discord.js' { public search(options?: MessageSearchOptions): Promise; public setAFKChannel(afkChannel: ChannelResolvable, reason?: string): Promise; public setAFKTimeout(afkTimeout: number, reason?: string): Promise; + public setBanner(banner: Base64Resolvable, reason?: string): Promise; public setChannelPosition(channel: string | GuildChannel, position: number, relative?: boolean): Promise; public setChannelPositions(channelPositions: ChannelPosition[]): Promise; public setDefaultMessageNotifications(defaultMessageNotifications: DefaultMessageNotifications, reason?: string): Promise; @@ -1877,6 +1878,7 @@ declare module 'discord.js' { afkChannel?: ChannelResolvable; systemChannel?: ChannelResolvable; afkTimeout?: number; + banner?: Base64Resolvable; icon?: Base64Resolvable; owner?: GuildMemberResolvable; splash?: Base64Resolvable;