From cfba6ffa61a11359f1c46955f9ccebe0ada39e0c Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 26 Mar 2023 20:17:38 -0400 Subject: [PATCH] Improve logging on guildFromChannel --- Client/controllers/botController.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/controllers/botController.js b/Client/controllers/botController.js index afda7d8..ebfb734 100644 --- a/Client/controllers/botController.js +++ b/Client/controllers/botController.js @@ -42,10 +42,10 @@ function checkIfGuildHasChannel(guildId, channelId, req){ function getGuildFromChannel(channelId, req){ const channel = req.discordClient.channels.cache.get(channelId); - if (!channel) return undefined; + if (!channel) return new Error("Error getting channel from client"); if (channel.guild) return channel.guild; - + return new Error("No Guild found with the given ID"); } @@ -73,12 +73,12 @@ exports.getStatus = (req, res) => { exports.joinServer = (req, res) => { const channelId = req.body.channelID; const presetName = req.body.presetName; - const guildId = getGuildFromChannel(channelId, req); + const guildObj = getGuildFromChannel(channelId, req); if (!channelId || !presetName || !guildId) return res.status(400).json({'message': "Request does not have all components to proceed"}); // join the sever - join({guildID: guildId, guildObj: client.guilds.cache.get(guildId), channelID: channelId, callback: () => { + join({guildID: guildId, guildObj: guildObj, channelID: channelId, callback: () => { return req.sendStatus(202); }}); }