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:
@@ -1,4 +1,5 @@
|
||||
import { checkIfConnectedToVC } from '../discordAudioBot/dab.mjs';
|
||||
import { checkIfDiscordVCConnected, joinDiscordVC, leaveDiscordVC, getDiscordUsername, checkIfClientIsOpen } from '../discordAudioBot/dabWrappers.mjs';
|
||||
import { getCurrentSystem } from '../op25Handler/op25Handler.mjs';
|
||||
|
||||
/**
|
||||
* Wrapper to log into the server
|
||||
@@ -27,19 +28,20 @@ export const sendNodeUpdateWrapper = async (socket, localNodeConfig) => {
|
||||
}
|
||||
|
||||
|
||||
export const nodeJoinServer = async (joinData) => {
|
||||
console.log("Join requested: ", joinData)
|
||||
// TODO - Implement logic to control OP25 for the requested channel/system
|
||||
/**
|
||||
* Join the requested server VC and listen to the requested system
|
||||
* @param {object} joinData The object containing all the information to join the server
|
||||
*/
|
||||
export const nodeJoinServer = async (joinData) => {
|
||||
await joinDiscordVC(joinData);
|
||||
}
|
||||
|
||||
// Join the requested channel with the requested ID
|
||||
initDiscordBotClient(joinData.clientID, joinData.system, client => {
|
||||
getVoiceChannelFromID(client, joinData.channelID).then(vc => {
|
||||
// Add the client object to the IO instance
|
||||
discordClients[vc.guild.id] = client;
|
||||
const connection = connectToChannel(vc);
|
||||
console.log("Bot Connected to VC");
|
||||
})
|
||||
});
|
||||
/**
|
||||
* Leave VC on the requested server
|
||||
* @param {string} guildId The guild ID to disconnect from VC
|
||||
*/
|
||||
export const nodeLeaveServer = async (guildId) => {
|
||||
await leaveDiscordVC(guildId);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +49,37 @@ export const nodeJoinServer = async (joinData) => {
|
||||
* Check if the bot is connected to a discord VC in the given server
|
||||
* @param {string} guildId The guild id to check the connection status in
|
||||
* @param {any} socketCallback The callback function to return the result to
|
||||
* @returns {any}
|
||||
* @callback {boolean} If the node is connected to VC in the given guild
|
||||
*/
|
||||
export const nodeCheckStatus = 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);
|
||||
}
|
||||
socketCallback(await checkIfDiscordVCConnected(guildId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the username of the bot in a given guild
|
||||
* (there may be a server nickname given to the bot in a certain guild)
|
||||
* @param {string} guildId The guild id to check the connection status in
|
||||
* @param {any} socketCallback The callback function to return the result to
|
||||
* @callback {any}
|
||||
*/
|
||||
export const nodeGetUsername = async (guildId, socketCallback) => {
|
||||
socketCallback(await getDiscordUsername(guildId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the local node has an open discord client in any server
|
||||
* @callback {boolean} If the node has an open discord client or not
|
||||
*/
|
||||
export const nodeCheckDiscordClientStatus = async (socketCallback) => {
|
||||
socketCallback(await checkIfClientIsOpen());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check what system the local node is currently listening to
|
||||
* @callback {boolean} If the node has an open discord client or not
|
||||
*/
|
||||
export const nodeCheckCurrentSystem = async (socketCallback) => {
|
||||
socketCallback(await getCurrentSystem());
|
||||
}
|
||||
Reference in New Issue
Block a user