Updates to join (server/client)

- Check if the available nodes are connected to a vc in the given guild
This commit is contained in:
Logan Cusano
2024-02-11 04:32:58 -05:00
parent b78fa8307d
commit ed33654b8c
4 changed files with 103 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
import { io } from "socket.io-client";
import { connectToChannel, initDiscordBotClient, getVoiceChannelFromID } from '../discordAudioBot/dab.mjs';
import { connectToChannel, initDiscordBotClient, getVoiceChannelFromID, checkIfConnectedToVC } from '../discordAudioBot/dab.mjs';
import { logIntoServerWrapper, sendNodeUpdateWrapper } from "./socketClientWrappers.mjs";
export const initSocketConnection = async (localNodeConfig) => {
@@ -25,8 +25,23 @@ export const initSocketConnection = async (localNodeConfig) => {
});
});
socket.on('node-leave', () => {
socket.on('node-leave', async () => {
console.log("Leave requested");
const connection = await getVoiceConnection(myVoiceChannel.guild.id);
if (connection) {
console.log("There is an open VC connection, closing it now");
connection.destroy();
}
});
socket.on('node-check-connected-status', async (guildId, socketCallback) => {
console.log("Requested status check");
if (await checkIfConnectedToVC(guildId)) {
console.log("There is an open VC connection");
socketCallback(true);
} else {
socketCallback(false);
}
});
socket.on('disconnect', () => {