Whenever I try to make my bot connect to two voice connections, it disconnects from the previous one. Is there a way to connect to multiple voice sockets using Discordie? If so, how?
Here is my code:
const Discordie = require(discordie);
const fs = require('fs');
const Events = Discordie.Events;
const client = new Discordie({autoReconnect: true});
client.autoReconnect.enable();
client.connect({token: token});
var channels = new Array();
var connections = new Object();
client.Dispatcher.on(Events.GATEWAY_READY, e => {
client.User.setStatus(online);
console.log(Connected as: + client.User.username);
process.title = Discord Bot: + client.User.username;
client.Channels.forEach((channel) => {
if (channel.name == 'cantina') channels.push(channel.id);
});
r.context.client = client;
r.displayPrompt();
});
client.Dispatcher.on(Events.CHANNEL_CREATE, (e) => {
if (e.channel.name == 'cantina') {
channels.push(e.channel.id);
}
});
client.Dispatcher.on(Events.VOICE_CHANNEL_JOIN, (e) => {
if (channels.includes(e.channel.id) && e.channel.members.length <= 2) {
e.channel.join().then((info) => {
var connection = info.voiceConnection;
connections[e.channel.id] = {
channel: e.channel,
connectionInfo : info,
connection: connection
}
play(e.channel, connection);
});
}
});
function play(channel, connection) {
//function to play the song
}