Files
discord.js/src/structures/VoiceChannel.js
2016-08-23 00:17:44 +01:00

48 lines
1.2 KiB
JavaScript

const GuildChannel = require('./GuildChannel');
const Collection = require('../util/Collection');
/**
* Represents a Server Voice Channel on Discord.
* @extends {GuildChannel}
*/
class VoiceChannel extends GuildChannel {
constructor(guild, data) {
super(guild, data);
/**
* The members in this Voice Channel.
* @type {Collection<String, GuildMember>}
*/
this.members = new Collection();
}
setup(data) {
super.setup(data);
/**
* The bitrate of this voice channel
* @type {Number}
*/
this.bitrate = data.bitrate;
/**
* The maximum amount of users allowed in this channel - 0 means unlimited.
* @type {Number}
*/
this.userLimit = data.user_limit;
}
/**
* Sets the bitrate of the channel
* @param {Number} bitrate the new bitrate
* @returns {Promise<VoiceChannel>}
* @example
* // set the bitrate of a voice channel
* voiceChannel.setBitrate(48000)
* .then(vc => console.log(`Set bitrate to ${vc.bitrate} for ${vc.name}`))
* .catch(console.log);
*/
setBitrate(bitrate) {
return this.rest.client.rest.methods.updateChannel(this, { bitrate });
}
}
module.exports = VoiceChannel;