Attempt to fix return bug
This commit is contained in:
@@ -5,11 +5,12 @@ const log = new DebugBuilder("client", "clientController");
|
||||
const path = require('path');
|
||||
const fork = require('child_process').fork;
|
||||
const discordBotPath = path.resolve('discord-bot/app.js');
|
||||
const {getVoiceConnection} = require("@discordjs/voice");
|
||||
const {replyToInteraction} = require("../utilities/messageHandler.js");
|
||||
// Commands
|
||||
const { ping } = require('../commands/ping.js');
|
||||
const { join } = require('../commands/join.js');
|
||||
const { leave } = require('../commands/leave.js');
|
||||
const { status } = require('../commands/status.js');
|
||||
|
||||
/**
|
||||
* Get an object of client guilds
|
||||
@@ -29,7 +30,7 @@ exports.getStatus = (res, req) => {
|
||||
log.DEBUG("Guild IDs: ", guildIds);
|
||||
var guildStatuses = []
|
||||
for (const guildID of guildIds){
|
||||
status({guildID: guildID, callback: (statusObj) => {
|
||||
this.status({guildID: guildID, callback: (statusObj) => {
|
||||
log.DEBUG("Status Object string: ", statusObj);
|
||||
if (!statusObj.voiceConnection) guildStatuses.push({ guildID : 201 });
|
||||
else guildStatuses.push({ guildID: 202 })
|
||||
@@ -59,4 +60,27 @@ exports.leaveServer = (res, req) => {
|
||||
leave({guildID: guildID, callback: (response) => {
|
||||
return res.sendStatus(202);
|
||||
}});
|
||||
}
|
||||
|
||||
exports.status = async function status({interaction= undefined, guildID= undefined, callback = undefined}) {
|
||||
//if (!interaction && !guildID) // Need error of sorts
|
||||
if (interaction){
|
||||
guildID = interaction.guild.id;
|
||||
}
|
||||
const voiceConnection = getVoiceConnection(guildID);
|
||||
|
||||
const statusObj = {
|
||||
"guildID": guildID, "voiceConnection": voiceConnection
|
||||
}
|
||||
|
||||
//log.DEBUG('Status Object: ', statusObj);
|
||||
|
||||
// get the status and return it accordingly (message reply / module)
|
||||
|
||||
if (interaction) {
|
||||
return replyToInteraction(interaction, "Pong! I have Aids and now you do too!");
|
||||
}
|
||||
else {
|
||||
callback(statusObj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user