mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
Fixed voice_connection.stopPlaying
Now unpipes before destroying
This commit is contained in:
@@ -150,6 +150,7 @@ export default class Server extends Equality {
|
||||
this.eventStopSpeaking(user);
|
||||
|
||||
channel.speaking.add(user);
|
||||
user.voiceChannel = channel;
|
||||
return true;
|
||||
}else{
|
||||
// bad
|
||||
@@ -161,6 +162,7 @@ export default class Server extends Equality {
|
||||
for(let chan of this.channels.getAll("type", "voice")){
|
||||
if(chan.speaking.has(user)){
|
||||
chan.speaking.remove(user);
|
||||
user.voiceChannel = null;
|
||||
return chan;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export default class User extends Equality{
|
||||
since : null,
|
||||
channel : null
|
||||
};
|
||||
this.voiceChannel = null;
|
||||
}
|
||||
|
||||
get avatarURL(){
|
||||
|
||||
@@ -97,12 +97,10 @@ export default class AudioEncoder {
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function () {
|
||||
console.log("end");
|
||||
reject("end");
|
||||
});
|
||||
|
||||
enc.stdout.on("close", function () {
|
||||
console.log("close");
|
||||
reject("close");
|
||||
});
|
||||
});
|
||||
@@ -130,12 +128,10 @@ export default class AudioEncoder {
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function () {
|
||||
console.log("end");
|
||||
reject("end");
|
||||
});
|
||||
|
||||
enc.stdout.on("close", function () {
|
||||
console.log("close");
|
||||
reject("close");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import AudioEncoder from "./AudioEncoder";
|
||||
import VoicePacket from "./VoicePacket";
|
||||
import StreamIntent from "./StreamIntent";
|
||||
import EventEmitter from "events";
|
||||
import unpipe from "unpipe";
|
||||
|
||||
export default class VoiceConnection extends EventEmitter {
|
||||
constructor(channel, client, session, token, server, endpoint) {
|
||||
@@ -62,13 +63,10 @@ export default class VoiceConnection extends EventEmitter {
|
||||
stopPlaying() {
|
||||
this.playing = false;
|
||||
this.playingIntent = null;
|
||||
if (this.streamProc) {
|
||||
this.streamProc.stdin.pause();
|
||||
this.streamProc.kill("SIGINT");
|
||||
}
|
||||
if(this.instream){
|
||||
if (this.instream) {
|
||||
//not all streams implement these...
|
||||
//and even file stream don't seem to implement them properly...
|
||||
unpipe(this.instream);
|
||||
if(this.instream.end) {
|
||||
this.instream.end();
|
||||
}
|
||||
@@ -77,6 +75,11 @@ export default class VoiceConnection extends EventEmitter {
|
||||
}
|
||||
this.instream = null;
|
||||
}
|
||||
if (this.streamProc) {
|
||||
this.streamProc.stdin.pause();
|
||||
this.streamProc.kill("SIGINT");
|
||||
this.streamProc = null;
|
||||
}
|
||||
}
|
||||
|
||||
playStream(stream, channels=2) {
|
||||
@@ -88,9 +91,6 @@ export default class VoiceConnection extends EventEmitter {
|
||||
|
||||
var length = 20;
|
||||
|
||||
if (self.playingIntent) {
|
||||
self.stopPlaying();
|
||||
}
|
||||
self.playing = true;
|
||||
var retStream = new StreamIntent();
|
||||
var onWarning = false;
|
||||
@@ -282,7 +282,6 @@ export default class VoiceConnection extends EventEmitter {
|
||||
|
||||
init() {
|
||||
var self = this;
|
||||
console.log("\n\nendpoint:", this.endpoint, "\n\n");
|
||||
dns.lookup(this.endpoint, (err, address, family) => {
|
||||
var vWS = self.vWS = new WebSocket("wss://" + this.endpoint, null, { rejectUnauthorized: false });
|
||||
this.endpoint = address;
|
||||
|
||||
Reference in New Issue
Block a user