Improvements to tests and from testing

- Moved OP25 start outside of PDAB start callback
- Added more logging
- Set the pdabProcess variable to false when closing the discord client
- Update test variable names
- Added new WIP pdabWrappers tests to test the full wrappers as the client would
This commit is contained in:
Logan Cusano
2024-04-28 03:21:03 -04:00
parent bf69e93e29
commit a353b9adbb
4 changed files with 56 additions and 27 deletions

View File

@@ -120,6 +120,7 @@ export const requestDiscordID = () => {
export const requestDiscordClientClose = () => {
return new Promise((res) => {
io.timeout(25000).emit('request_client_close');
pdabProcess = false;
res();
});
};

View File

@@ -8,16 +8,22 @@ let activeDiscordClient = undefined;
* @param {object} joinData The object containing all the information to join the server
*/
export const joinDiscordVC = async (joinData) => {
console.log("Join requested: ", joinData)
console.log("Join requested: ", joinData);
const connection = await new Promise(async (res) => {
// Check if a client already exists
console.log("Checking if there is a client open");
if (!await checkIfClientIsOpen()) {
console.log("There is no open client, starting it now");
// Open an instance of OP25
console.log("Starting OP25")
openOP25(joinData.system);
// Open a new client and join the requested channel with the requested ID
initDiscordBotClient(joinData.clientID, () => {
// Open an instance of OP25
openOP25(joinData.system);
console.log("Started PDAB")
// Add the client object to the IO instance
console.log("Connecting to channel")
connectToChannel(joinData.channelID, (connectionStatus) => {
console.log("Bot Connected to VC:", connectionStatus);
res(connectionStatus);
@@ -25,7 +31,9 @@ export const joinDiscordVC = async (joinData) => {
});
} else {
// Join the requested channel with the requested ID
// Add the client object to the IO instance
console.log("There is an open client");
console.log("Connecting to channel")
const connection = connectToChannel(joinData.channelID);
console.log("Bot Connected to VC::");
res(connection);