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); }}); }