Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setBanner method to Guild #3364

Merged
merged 4 commits into from Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/structures/Guild.js
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
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