feature/implement-bot-into-client-core #2

Merged
logan merged 42 commits from feature/implement-bot-into-client-core into master 2023-05-06 14:45:00 -04:00
Showing only changes of commit f5076d40cc - Show all commits

View File

@@ -19,7 +19,7 @@ function getGuilds(req) {
* @param {*} req The request object to use to check the discord client
*/
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);
return guild.channels;
}
@@ -40,13 +40,12 @@ function checkIfGuildHasChannel(guildId, channelId, req){
}
function getGuildFromChannel(channelId, req){
const guilds = getGuilds(req);
for (const guild in guilds){
if (checkIfGuildHasChannel(guild.id, channelId, req)) {
return guild;
break;
}
}
const channel = req.discordClient.channels.cache.get(channelId);
if (!channel) return undefined;
if (channel.guild) return channel.guild;
return new Error("No Guild found with the given ID");
}