From 8c855855cd5170dfcb48c9a0fcd5a81e7e51eb8f Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sat, 19 Aug 2017 20:15:02 -0700 Subject: [PATCH] Guild/systemchannel (#1799) * add cool system channel * Update Guild.js * Update Guild.js * Update Guild.js --- src/structures/Guild.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index e562cd46b..3b60e68be 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -141,6 +141,12 @@ class Guild { */ this.afkChannelID = data.afk_channel_id; + /** + * The ID of the system channel + * @type {?Snowflake} + */ + this.systemChannelID = data.system_channel_id; + /** * Whether embedded images are enabled on this guild * @type {boolean} @@ -303,6 +309,24 @@ class Guild { return this.members.get(this.ownerID); } + /** + * AFK voice channel for this guild + * @type {?VoiceChannel} + * @readonly + */ + get afkChannel() { + return this.client.channels.get(this.afkChannelID); + } + + /** + * System channel for this guild + * @type {?GuildChannel} + * @readonly + */ + get systemChannel() { + return this.client.channels.get(this.systemChannelID); + } + /** * If the client is connected to any voice channel in this guild, this will be the relevant VoiceConnection * @type {?VoiceConnection} @@ -650,6 +674,7 @@ class Guild { 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.systemChannel) _data.system_channel_id = this.client.resolver.resolveChannel(data.systemChannel).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; @@ -731,6 +756,16 @@ class Guild { return this.edit({ afkChannel }, reason); } + /** + * Edit the system channel of the guild. + * @param {ChannelResolvable} systemChannel The new system channel + * @param {string} [reason] Reason for changing the guild's system channel + * @returns {Promise} + */ + setSystemChannel(systemChannel, reason) { + return this.edit({ systemChannel }, reason); + } + /** * Edit the AFK timeout of the guild. * @param {number} afkTimeout The time in seconds that a user must be idle to be considered AFK