Guild/systemchannel (#1799)

* add cool system channel

* Update Guild.js

* Update Guild.js

* Update Guild.js
This commit is contained in:
Gus Caplan
2017-08-19 20:15:02 -07:00
committed by Crawl
parent b3216f26d6
commit e76ebb4fcb

View File

@@ -134,6 +134,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}
@@ -291,6 +297,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}
@@ -525,6 +549,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;
@@ -600,6 +625,16 @@ class Guild {
return this.edit({ afkChannel });
}
/**
* 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<Guild>}
*/
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