update bug in getting bot status

This commit is contained in:
Logan Cusano
2023-03-26 15:40:59 -04:00
parent 7b821687a9
commit 988683ab72

View File

@@ -13,22 +13,28 @@ const status = require('../commands/status.js');
/** /**
* Get an object of client guilds * Get an object of client guilds
* @param req The express request which includes the discord client
* @returns * @returns
*/ */
function getGuilds() { function getGuilds(req) {
return client.guilds.cache.map(guild => guild.id) return req.discordClient.guilds.cache.map(guild => guild.id)
} }
/** /**
* Get Status of the discord process * Get Status of the discord process
*/ */
exports.getStatus = (req, res) => { exports.getStatus = (req, res) => {
guildIds = getGuilds(req);
var guildStatuses = []
for (const guildID of guildIds){
status({guildID: guildID, callback: (statusObj) => { status({guildID: guildID, callback: (statusObj) => {
log.DEBUG("Status Object string: ", statusObj); log.DEBUG("Status Object string: ", statusObj);
if (!statusObj.voiceConnection) return req.sendStatus(201); if (!statusObj.voiceConnection) guildStatuses.push({ guildID : 201 });
return req.sendStatus(202); else guildStatuses.push({ guildID: 202 })
}}); }});
} }
return req.send(200).json(guildStatuses);
}
/** /**
* Start the bot and join the server and preset specified * Start the bot and join the server and preset specified