"use strict";

const Utils = require("../core/Utils");
const User = require("../models/User");
const IChannel = require("./IChannel");

// todo: multiserver voice

class IVoiceChannel extends IChannel {
  constructor(discordie, channelId) {
    super(discordie, channelId);
  }
  get members() {
    // todo: active members only?
  }
  get joined() {
    // todo: see what happens if we delete all channels with bot streaming
    return this._discordie.gatewaySocket.voiceState.channelId == this.id;
  }
  join(selfMute, selfDeaf, createNewVoiceConnection) {
    const argsArray = [].slice.call(arguments);
    const args = [this.guild_id, this.id].concat(argsArray);
    const vc = this._discordie.VoiceConnections;
    return vc._getOrCreate.apply(vc, args);
  }
  leave() {
    const v = this._discordie.VoiceConnections.getForChannel(this.channelId);
    if (v && v.gatewaySocket) v.gatewaySocket.disconnect();
  }
  getVoiceConnection() {
    return this._discordie.VoiceConnections.getForChannel(this.channelId);
  }
}

module.exports = IVoiceChannel;

"use strict";

const Utils = require("../core/Utils");
const User = require("../models/User");
const IChannel = require("./IChannel");

// todo: multiserver voice

class IVoiceChannel extends IChannel {
  constructor(discordie, channelId) {
    super(discordie, channelId);
  }
  get members() {
    // todo: active members only?
  }
  get joined() {
    // todo: see what happens if we delete all channels with bot streaming
    return this._discordie.gatewaySocket.voiceState.channelId == this.id;
  }
  join(selfMute, selfDeaf, createNewVoiceConnection) {
    const argsArray = [].slice.call(arguments);
    const args = [this.guild_id, this._channelId].concat(argsArray);
    const vc = this._discordie.VoiceConnections;
    return vc._getOrCreate.apply(vc, args);
  }
  leave() {
    const v = this._discordie.VoiceConnections.getForChannel(this._channelId);
    if (v && v.gatewaySocket) v.gatewaySocket.disconnect();
  }
  getVoiceConnection() {
    return this._discordie.VoiceConnections.getForChannel(this._channelId);
  }
}

module.exports = IVoiceChannel;

Fix leave and getVoiceConnection (IVoiceChannel)