Skip to content

Commit

Permalink
[Enhancement] Refactored guildMemberAdd
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 18, 2021
1 parent 20219f4 commit 1733e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions events/guildMemberAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,24 @@ 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:`,
embeds: [welcomeEmbed],
});
}

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;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/DatabaseConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
};

0 comments on commit 1733e70

Please sign in to comment.