mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Fixed process removing
This commit is contained in:
@@ -28,8 +28,14 @@ class AudioEncoder{
|
||||
]);
|
||||
|
||||
enc.stdout.on("readable", function() {
|
||||
callback(null, enc.stdout);
|
||||
resolve(enc.stdout)
|
||||
callback(null, {
|
||||
proc : enc,
|
||||
stream : enc.stdout
|
||||
});
|
||||
resolve({
|
||||
proc : enc,
|
||||
stream : enc.stdout
|
||||
});
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function() {
|
||||
|
||||
@@ -31,11 +31,15 @@ class VoiceConnection extends EventEmitter{
|
||||
this.playingIntent = null;
|
||||
this.playing = false;
|
||||
this.streamTime = 0;
|
||||
this.streamProc = null;
|
||||
this.init();
|
||||
}
|
||||
|
||||
stopPlaying() {
|
||||
this.playing=false;
|
||||
this.playingIntent = null;
|
||||
if(this.streamProc)
|
||||
this.streamProc.kill();
|
||||
}
|
||||
|
||||
playRawStream(stream) {
|
||||
@@ -166,9 +170,10 @@ class VoiceConnection extends EventEmitter{
|
||||
this.encoder
|
||||
.encodeFile(stream)
|
||||
.catch(error)
|
||||
.then(stream => {
|
||||
|
||||
var intent = self.playRawStream(stream);
|
||||
.then(data => {
|
||||
|
||||
self.streamProc = data.proc;
|
||||
var intent = self.playRawStream(data.stream);
|
||||
resolve(intent);
|
||||
callback(null, intent);
|
||||
|
||||
|
||||
15
src/index.js
15
src/index.js
@@ -20,6 +20,19 @@ a.on("message", m => {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m.content.startsWith("$$$ stop")){
|
||||
for(var channel of m.channel.server.channels){
|
||||
if(channel instanceof VoiceChannel){
|
||||
chan = channel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(a.internal.voiceConnections[chan]){
|
||||
var connection = a.internal.voiceConnections[chan];
|
||||
connection.stopPlaying();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(m.content.startsWith("$$$")){
|
||||
var chan;
|
||||
for(var channel of m.channel.server.channels){
|
||||
@@ -30,7 +43,7 @@ a.on("message", m => {
|
||||
}
|
||||
if(a.internal.voiceConnections[chan]){
|
||||
var connection = a.internal.voiceConnections[chan];
|
||||
connection.playFile("C:/users/amish/desktop/audio.mp3");
|
||||
connection.playFile("C:/users/amish/desktop/asdf.mp3");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user