rewrite voice state handling

This commit is contained in:
Amish Shah
2018-08-10 14:44:59 +01:00
parent 0f63c50c06
commit be5efea461
11 changed files with 187 additions and 144 deletions

View File

@@ -1,5 +1,4 @@
const GuildChannel = require('./GuildChannel');
const Collection = require('../util/Collection');
const { browser } = require('../util/Constants');
const Permissions = require('../util/Permissions');
const { Error } = require('../errors');
@@ -9,17 +8,6 @@ const { Error } = require('../errors');
* @extends {GuildChannel}
*/
class VoiceChannel extends GuildChannel {
constructor(guild, data) {
super(guild, data);
/**
* The members in this voice channel
* @type {Collection<Snowflake, GuildMember>}
* @name VoiceChannel#members
*/
Object.defineProperty(this, 'members', { value: new Collection() });
}
_patch(data) {
super._patch(data);
/**
@@ -35,6 +23,17 @@ class VoiceChannel extends GuildChannel {
this.userLimit = data.user_limit;
}
/**
* The members in this voice channel
* @type {Collection<Snowflake, GuildMember>}
* @name VoiceChannel#members
*/
get members() {
return this.guild.voiceStates
.filter(state => state.channelID === this.id && state.member)
.map(state => state.member);
}
/**
* The voice connection for this voice channel, if the client is connected
* @type {?VoiceConnection}