From e3232bdb2bc91a418b09ff411e7ddf105902c396 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 25 Jun 2017 00:03:37 +0200 Subject: [PATCH] added Guild#setExplicitContentFilter (#1583) --- src/structures/Guild.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 41d2ebd9c..8fa1e20ef 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -497,6 +497,7 @@ class Guild { * @property {string} [name] The name of the guild * @property {string} [region] The region of the guild * @property {number} [verificationLevel] The verification level of the guild + * @property {number} [explicitContentFilter] The level of the explicit content filter * @property {ChannelResolvable} [afkChannel] The AFK channel of the guild * @property {number} [afkTimeout] The AFK timeout of the guild * @property {Base64Resolvable} [icon] The icon of the guild @@ -518,7 +519,28 @@ class Guild { * .catch(console.error); */ edit(data) { - return this.client.rest.methods.updateGuild(this, data); + const _data = {}; + if (data.name) _data.name = data.name; + if (data.region) _data.region = data.region; + if (typeof data.verificationLevel !== 'undefined') _data.verification_level = Number(data.verificationLevel); + if (data.afkChannel) _data.afk_channel_id = this.client.resolver.resolveChannel(data.afkChannel).id; + if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout); + if (data.icon) _data.icon = this.client.resolver.resolveBase64(data.icon); + if (data.owner) _data.owner_id = this.client.resolver.resolveUser(data.owner).id; + if (data.splash) _data.splash = this.client.resolver.resolveBase64(data.splash); + if (typeof data.explicitContentFilter !== 'undefined') { + _data.explicit_content_filter = Number(data.explicitContentFilter); + } + return this.client.rest.methods.updateGuild(this, _data); + } + + /** + * Edit the level of the explicit content filter. + * @param {number} explicitContentFilter The new level of the explicit content filter + * @returns {Promise} + */ + setExplicitContentFilter(explicitContentFilter) { + return this.edit({ explicitContentFilter }); } /**