Skip to content

Commit

Permalink
Merge pull request #26 from Antares-Network/development
Browse files Browse the repository at this point in the history
update logging to for TOS assurance
  • Loading branch information
nathen418 authored Feb 10, 2021
2 parents c994977 + 0f94a9b commit 257e0d0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
29 changes: 29 additions & 0 deletions actions/logToConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.blue, `[${member.guild.name}]`.green, `[${member.user.username}]`.yellow)
try {
bot.channels.cache.get(process.env.REPORTING_CHANNEL).send(`**MEMBER JOIN** - [${member.guild.name}] [${member.user.username}]`)
} catch (e) {
console.log(e);
}
},

memberLeave: async function (member) {
console.log(`MEMBER LEAVE`.blue, `[${member.guild.name}]`.green, `[${member.user.username}]`.yellow)
try {
bot.channels.cache.get(process.env.REPORTING_CHANNEL).send(`**MEMBER LEAVE** - [${member.guild.name}] [${member.user.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);
}
}
}
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 257e0d0

Please sign in to comment.