Log messageDelete and messageUpdate

Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
loicbersier 2020-04-30 22:50:12 +02:00
parent 320ac3a3f0
commit 3dd73b9caf
2 changed files with 57 additions and 0 deletions

View file

@ -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;

View file

@ -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;