Implementing disconnection of discord client

This commit is contained in:
Logan Cusano
2024-04-06 01:02:42 -04:00
parent ea63abcb93
commit 62c00eec09
2 changed files with 26 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
import { connectToChannel, leaveVoiceChannel, checkIfConnectedToVC, initDiscordBotClient, requestDiscordUsername, requestDiscordID } from './pdabHandler.mjs';
import { connectToChannel, leaveVoiceChannel, checkIfConnectedToVC, initDiscordBotClient, requestDiscordUsername, requestDiscordID, requestDiscordClientClose } from './pdabHandler.mjs';
import { openOP25, closeOP25 } from '../op25Handler/op25Handler.mjs';
let activeDiscordClient = undefined;
@@ -42,14 +42,15 @@ export const joinDiscordVC = async (joinData) => {
export const leaveDiscordVC = async (guildId) => {
console.log("Leave requested");
if (await checkIfConnectedToVC(guildId)) {
await leaveVoiceChannel(guildId, async (clientRemainsOpen) => {
if (!clientRemainsOpen) {
console.log("There are no open VC connections");
// TODO DELETE comment DEV ONLY await closeOP25();
const clientRemainsOpen = await leaveVoiceChannel(guildId);
console.log("Client should remain open: ", clientRemainsOpen);
if (!clientRemainsOpen) {
console.log("There are no open VC connections");
// TODO DELETE comment DEV ONLY await closeOP25();
// TODO Close the python client
}
})
// Close the python client
await requestDiscordClientClose();
}
}
}