Attempt to fix return bug
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
const { DebugBuilder } = require("../utilities/debugBuilder.js");
|
const { DebugBuilder } = require("../utilities/debugBuilder.js");
|
||||||
const log = new DebugBuilder("client-bot", "status");
|
const log = new DebugBuilder("client-bot", "status");
|
||||||
// Modules
|
// Modules
|
||||||
const {getVoiceConnection} = require("@discordjs/voice");
|
const { status } = require('../controllers/botController');
|
||||||
// Utilities
|
// Utilities
|
||||||
const {replyToInteraction} = require("../utilities/messageHandler.js");
|
|
||||||
const { SlashCommandBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -14,30 +14,6 @@ module.exports = {
|
|||||||
example: "status",
|
example: "status",
|
||||||
isPrivileged: false,
|
isPrivileged: false,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
await this.status({ interaction: interaction });
|
await status({ interaction: interaction });
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,12 @@ const log = new DebugBuilder("client", "clientController");
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
const discordBotPath = path.resolve('discord-bot/app.js');
|
const discordBotPath = path.resolve('discord-bot/app.js');
|
||||||
|
const {getVoiceConnection} = require("@discordjs/voice");
|
||||||
|
const {replyToInteraction} = require("../utilities/messageHandler.js");
|
||||||
// Commands
|
// Commands
|
||||||
const { ping } = require('../commands/ping.js');
|
const { ping } = require('../commands/ping.js');
|
||||||
const { join } = require('../commands/join.js');
|
const { join } = require('../commands/join.js');
|
||||||
const { leave } = require('../commands/leave.js');
|
const { leave } = require('../commands/leave.js');
|
||||||
const { status } = require('../commands/status.js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an object of client guilds
|
* Get an object of client guilds
|
||||||
@@ -29,7 +30,7 @@ exports.getStatus = (res, req) => {
|
|||||||
log.DEBUG("Guild IDs: ", guildIds);
|
log.DEBUG("Guild IDs: ", guildIds);
|
||||||
var guildStatuses = []
|
var guildStatuses = []
|
||||||
for (const guildID of guildIds){
|
for (const guildID of guildIds){
|
||||||
status({guildID: guildID, callback: (statusObj) => {
|
this.status({guildID: guildID, callback: (statusObj) => {
|
||||||
log.DEBUG("Status Object string: ", statusObj);
|
log.DEBUG("Status Object string: ", statusObj);
|
||||||
if (!statusObj.voiceConnection) guildStatuses.push({ guildID : 201 });
|
if (!statusObj.voiceConnection) guildStatuses.push({ guildID : 201 });
|
||||||
else guildStatuses.push({ guildID: 202 })
|
else guildStatuses.push({ guildID: 202 })
|
||||||
@@ -59,4 +60,27 @@ exports.leaveServer = (res, req) => {
|
|||||||
leave({guildID: guildID, callback: (response) => {
|
leave({guildID: guildID, callback: (response) => {
|
||||||
return res.sendStatus(202);
|
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