From 1733e70b3122f94620c58038fee38e3d53b51fe0 Mon Sep 17 00:00:00 2001 From: naseif Date: Thu, 18 Nov 2021 08:52:57 +0000 Subject: [PATCH] [Enhancement] Refactored guildMemberAdd --- events/guildMemberAdd.js | 21 ++++++++++----------- modules/DatabaseConnection.js | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 47b5c7d..9b07e75 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -35,11 +35,8 @@ module.exports = { ], }; - if (checkCustomChannel) { - const customchannel = guild.guild.channels.cache.find( - (channel) => channel.id === checkCustomChannel - ); - return customchannel.send({ + const sendWelcome = (channel) => { + return channel.send({ content: `Hey ${guild.toString()}, Welcome to ${ guild.guild.name }! :partying_face:`, @@ -47,13 +44,15 @@ module.exports = { }); } + if (checkCustomChannel) { + const customchannel = guild.guild.channels.cache.find( + (channel) => channel.id === checkCustomChannel + ); + sendWelcome(customchannel) + } + if (guild.guild.systemChannel) { - guild.guild.systemChannel.send({ - content: `Hey ${guild.toString()}, Welcome to ${ - guild.guild.name - }! :partying_face:`, - embeds: [welcomeEmbed], - }); + sendWelcome(guild.guild.systemChannel) } else { return; } diff --git a/modules/DatabaseConnection.js b/modules/DatabaseConnection.js index d4811b0..8528dae 100644 --- a/modules/DatabaseConnection.js +++ b/modules/DatabaseConnection.js @@ -19,9 +19,9 @@ module.exports.connectDatabase = (mongourl, client) => { client.logger("[DB] DATABASE CONNECTED"); }); mongoose.connection.on("err", (err) => { - console.log(`Mongoose connection error: \n ${err.stack}`, "error"); + client.logger(`Mongoose connection error: \n ${err.stack}`, "error"); }); mongoose.connection.on("disconnected", () => { - console.log("Mongoose disconnected"); + client.logger("Mongoose disconnected", "error"); }); };