Improve logging on guildFromChannel
This commit is contained in:
@@ -42,10 +42,10 @@ function checkIfGuildHasChannel(guildId, channelId, req){
|
|||||||
function getGuildFromChannel(channelId, req){
|
function getGuildFromChannel(channelId, req){
|
||||||
const channel = req.discordClient.channels.cache.get(channelId);
|
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;
|
if (channel.guild) return channel.guild;
|
||||||
|
|
||||||
return new Error("No Guild found with the given ID");
|
return new Error("No Guild found with the given ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,12 +73,12 @@ exports.getStatus = (req, res) => {
|
|||||||
exports.joinServer = (req, res) => {
|
exports.joinServer = (req, res) => {
|
||||||
const channelId = req.body.channelID;
|
const channelId = req.body.channelID;
|
||||||
const presetName = req.body.presetName;
|
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"});
|
if (!channelId || !presetName || !guildId) return res.status(400).json({'message': "Request does not have all components to proceed"});
|
||||||
|
|
||||||
// join the sever
|
// 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);
|
return req.sendStatus(202);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user