From 3dd73b9caf3fd6a58a413ae958d8771ec7a15aed Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 30 Apr 2020 22:50:12 +0200 Subject: [PATCH] Log messageDelete and messageUpdate Signed-off-by: loicbersier --- event/listeners/log/messageDelete.js | 28 +++++++++++++++++++++++++++ event/listeners/log/messageUpdate.js | 29 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 event/listeners/log/messageDelete.js create mode 100644 event/listeners/log/messageUpdate.js diff --git a/event/listeners/log/messageDelete.js b/event/listeners/log/messageDelete.js new file mode 100644 index 0000000..12f2ba1 --- /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 0000000..8f54a08 --- /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