Log messageDelete and messageUpdate
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
320ac3a3f0
commit
3dd73b9caf
2 changed files with 57 additions and 0 deletions
28
event/listeners/log/messageDelete.js
Normal file
28
event/listeners/log/messageDelete.js
Normal 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;
|
29
event/listeners/log/messageUpdate.js
Normal file
29
event/listeners/log/messageUpdate.js
Normal 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;
|
Loading…
Reference in a new issue