diff --git a/event/listeners/log/messageDelete.js b/event/listeners/log/messageDelete.js new file mode 100644 index 00000000..12f2ba18 --- /dev/null +++ b/event/listeners/log/messageDelete.js @@ -0,0 +1,28 @@ +const { Listener } = require('discord-akairo'); +const LogStats = require('../../../models/').LogStats; + +class messageDeleteListener extends Listener { + constructor() { + super('messageDelete', { + emitter: 'client', + event: 'messageDelete' + }); + } + + async exec(message) { + const logStats = await LogStats.findOne({where: {guild: message.guild.id}}); + if (logStats) { + const channel = this.client.channels.resolve(await logStats.get('channel')); + let Embed = this.client.util.embed() + .setColor('NAVY') + .setAuthor(`${message.author.username}#${message.author.discriminator}`) + .setTitle(`${message.author.username} deleted their message in ${message.channel.name}`) + .setDescription(message) + .setFooter(`Author ID: ${message.author.id}`) + .setTimestamp(); + + channel.send(Embed); + } + } +} +module.exports = messageDeleteListener; \ No newline at end of file diff --git a/event/listeners/log/messageUpdate.js b/event/listeners/log/messageUpdate.js new file mode 100644 index 00000000..8f54a08c --- /dev/null +++ b/event/listeners/log/messageUpdate.js @@ -0,0 +1,29 @@ +const { Listener } = require('discord-akairo'); +const LogStats = require('../../../models/').LogStats; + +class messageUpdateListener extends Listener { + constructor() { + super('messageUpdate', { + emitter: 'client', + event: 'messageUpdate' + }); + } + + async exec(oldMessage, newMessage) { + const logStats = await LogStats.findOne({where: {guild: newMessage.guild.id}}); + if (logStats) { + const channel = this.client.channels.resolve(await logStats.get('channel')); + let Embed = this.client.util.embed() + .setColor('NAVY') + .setAuthor(`${newMessage.author.username}#${newMessage.author.discriminator}`) + .setTitle(`${newMessage.author.username} modified their message in ${newMessage.channel.name}`) + .addField('Previously', oldMessage, true) + .addField('Currently', newMessage, true) + .setFooter(`Author ID: ${newMessage.author.id}`) + .setTimestamp(); + + channel.send(Embed); + } + } +} +module.exports = messageUpdateListener; \ No newline at end of file