Working on #9
- Can join and leave from voice channels - Will check to make sure that the bot is in a given system or no system before joining - Cleaned up the socket client with wrappers - Added a new module to handle subprocesses for the client - Beginning workings on OP25 handler - Added OP25 config object generator with config exporter
This commit is contained in:
@@ -182,6 +182,51 @@ export const getAllSocketsConnectedToVC = async (nodeIo, guildId) => {
|
||||
return socketsConnectedToVC;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the given node has an open discord client
|
||||
* @param {any} openSocket The open socket connection with the node to check
|
||||
* @returns {boolean} If the given node has an open discord client or not
|
||||
*/
|
||||
export const checkIfNodeHasOpenDiscordClient = async (openSocket) => {
|
||||
// Check the open socket to see if the node has an open discord client
|
||||
let hasOpenDiscordClient = false;
|
||||
await new Promise((res) => {
|
||||
openSocket.emit('node-check-discord-open-client', (status) => {
|
||||
if (status) {
|
||||
console.log("Socket has an open discord client:", openSocket.node.name, status);
|
||||
hasOpenDiscordClient = true;
|
||||
} else {
|
||||
console.log("Socket does NOT have an open discord client:", openSocket.node.name);
|
||||
}
|
||||
res();
|
||||
})
|
||||
});
|
||||
|
||||
return hasOpenDiscordClient;
|
||||
}
|
||||
|
||||
export const getNodeCurrentListeningSystem = async (openSocket) => {
|
||||
const hasOpenClient = checkIfNodeHasOpenDiscordClient(openSocket);
|
||||
if (!hasOpenClient) return undefined;
|
||||
|
||||
// check what system the socket is listening to
|
||||
let currentSystem = undefined;
|
||||
await new Promise((res) => {
|
||||
openSocket.emit('node-check-current-system', (system) => {
|
||||
if (system) {
|
||||
console.log("Socket is listening to system:", openSocket.node.name, system);
|
||||
currentSystem = system;
|
||||
} else {
|
||||
console.log("Socket is not currently listening to a system:", openSocket.node.name);
|
||||
}
|
||||
res();
|
||||
})
|
||||
});
|
||||
|
||||
return currentSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper to check if the given NUID is connected to a VC
|
||||
* @param {any} nodeIo The nodeIo object that contains the IO server
|
||||
|
||||
Reference in New Issue
Block a user