mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Minor fixes
This commit is contained in:
@@ -513,6 +513,24 @@ class Client extends EventEmitter {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
//def joinVoiceChannel
|
||||
joinVoiceChannel(channel, callback=function(err){}){
|
||||
var self = this;
|
||||
return new Promise((resolve, reject)=>{
|
||||
|
||||
self.internal.joinVoiceChannel(channel)
|
||||
.then(chan => {
|
||||
callback(null, chan);
|
||||
resolve(chan);
|
||||
})
|
||||
.catch(err => {
|
||||
callback(err);
|
||||
reject(err);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
@@ -67,7 +67,10 @@ class InternalClient {
|
||||
token = data.d.token;
|
||||
endpoint = data.d.endpoint;
|
||||
|
||||
self.voiceConnections[channel] = new VoiceConnection(channel, self.client, session, token, server, endpoint);
|
||||
var chan = self.voiceConnections[channel] = new VoiceConnection(channel, self.client, session, token, server, endpoint);
|
||||
|
||||
chan.on("ready", resolve);
|
||||
chan.on("error", reject);
|
||||
|
||||
}
|
||||
if(fired >= 2){
|
||||
@@ -822,7 +825,6 @@ class InternalClient {
|
||||
.set("authorization", self.token)
|
||||
.send(data)
|
||||
.end(function (err) {
|
||||
console.log(err);
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
|
||||
@@ -27,8 +27,6 @@ class AudioEncoder{
|
||||
"pipe:1"
|
||||
]);
|
||||
|
||||
var rcvd = 0;
|
||||
|
||||
enc.stdout.on("readable", function() {
|
||||
callback(null, enc.stdout);
|
||||
resolve(enc.stdout)
|
||||
|
||||
11
src/index.js
11
src/index.js
@@ -12,7 +12,10 @@ a.on("message", m => {
|
||||
if(m.content === "&init"){
|
||||
for(var channel of m.channel.server.channels){
|
||||
if(channel instanceof VoiceChannel){
|
||||
a.internal.joinVoiceChannel(channel).catch(error);
|
||||
a.joinVoiceChannel(channel).catch(error)
|
||||
.then(connection => {
|
||||
connection.playFile("C:/users/amish/desktop/asdf.mp3");
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -26,14 +29,14 @@ a.on("message", m => {
|
||||
}
|
||||
}
|
||||
if(a.internal.voiceConnections[chan]){
|
||||
connection = a.internal.voiceConnections[chan];
|
||||
connection
|
||||
var connection = a.internal.voiceConnections[chan];
|
||||
connection.playFile("C:/users/amish/desktop/audio.mp3");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function error(e){
|
||||
console.log(e);
|
||||
console.log(e.stack);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user