feature/implement-bot-into-client-core #2
@@ -19,7 +19,7 @@ function getGuilds(req) {
|
|||||||
* @param {*} req The request object to use to check the discord client
|
* @param {*} req The request object to use to check the discord client
|
||||||
*/
|
*/
|
||||||
function getChannels(guildId, req) {
|
function getChannels(guildId, req) {
|
||||||
const guild = req.discordClient.guilds.cache.get(guildId);
|
const guild = req.discordClient.guilds.find(guildId);
|
||||||
log.DEBUG("Found Guild channels with guild", guild.channels, guild);
|
log.DEBUG("Found Guild channels with guild", guild.channels, guild);
|
||||||
return guild.channels;
|
return guild.channels;
|
||||||
}
|
}
|
||||||
@@ -40,13 +40,12 @@ function checkIfGuildHasChannel(guildId, channelId, req){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getGuildFromChannel(channelId, req){
|
function getGuildFromChannel(channelId, req){
|
||||||
const guilds = getGuilds(req);
|
const channel = req.discordClient.channels.cache.get(channelId);
|
||||||
for (const guild in guilds){
|
|
||||||
if (checkIfGuildHasChannel(guild.id, channelId, req)) {
|
if (!channel) return undefined;
|
||||||
return guild;
|
|
||||||
break;
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user