mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Basic fixes, added test script
This commit is contained in:
@@ -48,7 +48,27 @@ var InternalClient = (function () {
|
||||
this.resolver = new Resolver(this);
|
||||
}
|
||||
|
||||
//def joinVoiceChannel()
|
||||
//def leaveVoiceChannel
|
||||
|
||||
InternalClient.prototype.leaveVoiceChannel = function leaveVoiceChannel(chann) {
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
var channel = self.resolver.resolveVoiceChannel(chann);
|
||||
|
||||
if (channel) {
|
||||
if (self.voiceConnections[channel]) {
|
||||
var chan = self.voiceConnections[channel];
|
||||
chan.stopPlaying();
|
||||
self.voiceConnections.remove(chan);
|
||||
resolve();
|
||||
}
|
||||
} else {
|
||||
reject(new Error("voice channel does not exist"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//def joinVoiceChannel
|
||||
|
||||
InternalClient.prototype.joinVoiceChannel = function joinVoiceChannel(chann) {
|
||||
var self = this;
|
||||
@@ -57,9 +77,7 @@ var InternalClient = (function () {
|
||||
var channel = self.resolver.resolveVoiceChannel(chann);
|
||||
|
||||
if (channel) {
|
||||
if (!self.voiceConnections[channel]) {
|
||||
|
||||
self.voiceConnections[channel] = {};
|
||||
if (!self.voiceConnections.get("id", channel.id)) {
|
||||
|
||||
var session,
|
||||
token,
|
||||
@@ -76,7 +94,7 @@ var InternalClient = (function () {
|
||||
token = data.d.token;
|
||||
endpoint = data.d.endpoint;
|
||||
|
||||
var chan = self.voiceConnections[channel] = new VoiceConnection(channel, self.client, session, token, server, endpoint);
|
||||
var chan = self.voiceConnections.add(new VoiceConnection(channel, self.client, session, token, server, endpoint));
|
||||
|
||||
chan.on("ready", resolve);
|
||||
chan.on("error", reject);
|
||||
|
||||
@@ -25,6 +25,7 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
if (!Opus) {
|
||||
console.log("HEY! WATCH OUT\n\n discord.js needs node-opus, you don't have it installed.");
|
||||
}
|
||||
this.id = channel.id;
|
||||
this.voiceChannel = channel;
|
||||
this.client = client;
|
||||
this.session = session;
|
||||
@@ -64,13 +65,13 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
if (self.playingIntent) {
|
||||
self.stopPlaying();
|
||||
}
|
||||
|
||||
self.playing = true;
|
||||
var retStream = new StreamIntent();
|
||||
var onWarning = false;
|
||||
self.playingIntent = retStream;
|
||||
|
||||
function send() {
|
||||
if (!self.playingIntent) {
|
||||
if (!self.playingIntent || !self.playing) {
|
||||
self.setSpeaking(false);
|
||||
retStream.emit("end");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user