Improve logging on guildFromChannel

This commit is contained in:
Logan Cusano
2023-03-26 20:17:38 -04:00
parent f5076d40cc
commit cfba6ffa61

View File

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