I have come a long way from when I first started learning to code however, this is one thing that has eluded me. I need to add a couple of things into an event on my bot however it can become unreachable if logging is disabled as it returns, what is the general way to do something like this?
const id = db.prepare(`SELECT channel FROM logging WHERE guildid = ${member.guild.id};`).get();
if (!id) return;
const logs = id.channel;
const logembed = new MessageEmbed()
.setAuthor('Member Joined', member.user.avatarURL())
.setDescription(`<@${member.user.id}> - ${member.user.tag}`)
.setColor(color)
.setFooter(`ID: ${member.user.id}`)
.setTimestamp();
bot.channels.cache.get(logs).send(logembed);
// Example
// If I do code here, but logs are disabled, it's unreachable as the above returns.
};