Skip to content

Commit

Permalink
feat(Guild): add banner to edit method and add setBanner method (#3364)
Browse files Browse the repository at this point in the history
* add setBanner method to Guild

* typos fixed & typings added

* more typings

* docs(Guild): add banner to GuildEditData
  • Loading branch information
Jisagi authored and SpaceEEC committed Jul 11, 2019
1 parent 4069d00 commit adb0823
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ class Guild extends Base {
* @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} [banner] The banner of the guild
* @property {DefaultMessageNotifications|number} [defaultMessageNotifications] The default message notifications
*/

Expand Down Expand Up @@ -802,6 +803,7 @@ class Guild extends Base {
if (typeof data.icon !== 'undefined') _data.icon = data.icon;
if (data.owner) _data.owner_id = this.client.users.resolve(data.owner).id;
if (data.splash) _data.splash = data.splash;
if (data.banner) _data.banner = data.banner;
if (typeof data.explicitContentFilter !== 'undefined') {
_data.explicit_content_filter = Number(data.explicitContentFilter);
}
Expand Down Expand Up @@ -971,6 +973,20 @@ class Guild extends Base {
return this.edit({ splash: await DataResolver.resolveImage(splash), reason });
}

/**
* Sets a new guild banner.
* @param {Base64Resolvable|BufferResolvable} banner The new banner of the guild
* @param {string} [reason] Reason for changing the guild's banner
* @returns {Promise<Guild>}
* @example
* guild.setBanner('./banner.png')
* .then(updated => console.log('Updated the guild banner'))
* .catch(console.error);
*/
async setBanner(banner, reason) {
return this.edit({ banner: await DataResolver.resolveImage(banner), reason });
}

/**
* The data needed for updating a channel's position.
* @typedef {Object} ChannelPosition
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ declare module 'discord.js' {
public member(user: UserResolvable): GuildMember | null;
public setAFKChannel(afkChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
public setBanner(banner: Base64Resolvable | null, reason?: string): Promise<Guild>;
public setChannelPositions(channelPositions: ChannelPosition[]): Promise<Guild>;
public setDefaultMessageNotifications(defaultMessageNotifications: DefaultMessageNotifications | number, reason?: string): Promise<Guild>;
public setEmbed(embed: GuildEmbedData, reason?: string): Promise<Guild>;
Expand Down Expand Up @@ -1947,6 +1948,7 @@ declare module 'discord.js' {
icon?: Base64Resolvable;
owner?: GuildMemberResolvable;
splash?: Base64Resolvable;
banner?: Base64Resolvable;
}

interface GuildEmbedData {
Expand Down

0 comments on commit adb0823

Please sign in to comment.