diff --git a/actions/logToConsole.js b/actions/logToConsole.js index 5a0a59c6..03d6680e 100644 --- a/actions/logToConsole.js +++ b/actions/logToConsole.js @@ -11,10 +11,39 @@ module.exports = { } messageLog.log(message); }, + message: function (guild, message) { console.log(`MESSAGE`.magenta, `[${guild.name}]`.green, `[${message.channel.name}]`.blue, `[${message.author.username}]`.yellow, `--`.grey, `${message.content}`.cyan) }, + dm: function (message) { console.log(`DM`.blue, `[${message.author.username}]`.yellow, `--`.grey, `${message.content}`.cyan) + }, + + memberJoin: async function (member) { + console.log(`MEMBER JOIN`.teal, `[${member.guild.name}]`.green, `[${member.username}]`.yellow) + try { + bot.channels.cache.get(process.env.REPORTING_CHANNEL).send(`**MEMBER JOIN** - [${member.guild.name}] [${member.username}]`) + } catch (e) { + console.log(e); + } + }, + + memberLeave: async function (member) { + console.log(`MEMBER LEAVE`.teal, `[${member.guild.name}]`.green, `[${member.username}]`.yellow) + try { + bot.channels.cache.get(process.env.REPORTING_CHANNEL).send(`**MEMBER LEAVE** - [${member.guild.name}] [${member.username}]`) + } catch (e) { + console.log(e); + } + }, + + guildUpdate: async function (oldGuild, newGuild) { + console.log(`GUILD UPDATE`.yellow, `[${oldGuild.name}]`.green, `--->`.grey, `[${newGuild.name}]`.blue) + try { + bot.channels.cache.get(process.env.REPORTING_CHANNEL).send(`**GUILD UPDATE** - [${oldGuild.name}] ---> [${newGuild.name}]`) + } catch (e) { + console.log(e); + } } } \ No newline at end of file diff --git a/index.js b/index.js index 1f5f5cb4..559c2c3d 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ const piiModel = require('./models/pii'); const piiCreate = require('./actions/piiCreate'); const counting = require('./functions/counting'); const messageLog = require('./actions/messageLog') +const logToConsole = require('./actions/logToConsole') global.botVersion = "1.3.2"; @@ -43,9 +44,9 @@ bot.registry unknownCommand: false }) .registerCommandsIn(path.join(__dirname, 'commands')); - + bot.on('message', async (message) => { - + if (message.author.bot) return; // return cause the message was sent by a bot try { console.log(`MESSAGE`.magenta, `[${message.guild.name}]`.green, `[${message.channel.name}]`.blue, `[${message.author.username}]`.yellow, `--`.grey, `${message.content}`.cyan) @@ -92,7 +93,7 @@ bot.on('guildMemberAdd', async (member) => { try { await piiModel.findOneAndUpdate({ GUILD_ID: member.guild.id }, { $set: { GUILD_MEMBERS: memberList } }, { new: true }); await guildModel.findOneAndUpdate({ GUILD_ID: member.guild.id }, { $set: { GUILD_MEMBERS: member.guild.memberCount } }, { new: true }); - console.log(`MEMBER JOIN`.teal, `[${member.guild.name}]`.green, `[${member.username}]`.yellow) + logToConsole.memberJoin(member); } catch (e) { console.log(e); } @@ -104,16 +105,16 @@ bot.on('guildMemberRemove', async (member) => { try { await piiModel.findOneAndUpdate({ GUILD_ID: member.guild.id }, { $set: { GUILD_MEMBERS: memberList } }, { new: true }); await guildModel.findOneAndUpdate({ GUILD_ID: member.guild.id }, { $set: { GUILD_MEMBERS: member.guild.memberCount } }, { new: true }); - console.log(`MEMBER LEAVE`.yellow, `[${member.guild.name}]`.green, `[${member.username}]`.yellow) + logToConsole.memberLeave(member); } catch (e) { console.log(e); } }) -bot.on('guildUpdate', async (oldGuild, newGuild) => { +bot.on('guildUpdate', async (oldGuild, newGuild) => { try { await guildModel.findOneAndUpdate({ GUILD_ID: newGuild.id }, { $set: { GUILD_NAME: newGuild.name } }, { new: true }); - console.log(`GUILD UPDATE`.yellow, `[${oldGuild.name}]`.green, `--->`.grey, `[${newGuild.name}]`.blue) + logToConsole.guildUpdate(oldGuild, newGuild); } catch (e) { console.log(e); }