forked from Supositware/Haha-Yes
Log role deletion
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
22acd163be
commit
70e91b9175
1 changed files with 38 additions and 0 deletions
38
event/listeners/log/roleDelete.js
Normal file
38
event/listeners/log/roleDelete.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
const { Listener } = require('discord-akairo');
|
||||||
|
const LogStats = require('../../../models/').LogStats;
|
||||||
|
|
||||||
|
class roleDeleteListener extends Listener {
|
||||||
|
constructor() {
|
||||||
|
super('roleDelete', {
|
||||||
|
emitter: 'client',
|
||||||
|
event: 'roleDelete'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(role) {
|
||||||
|
const guild = role.guild;
|
||||||
|
const logStats = await LogStats.findOne({where: {guild: guild.id}});
|
||||||
|
if (logStats) {
|
||||||
|
const fetchedLogs = await guild.fetchAuditLogs({
|
||||||
|
limit: 1,
|
||||||
|
type: 'ROLE_DELETE',
|
||||||
|
});
|
||||||
|
|
||||||
|
const creationLog = fetchedLogs.entries.first();
|
||||||
|
|
||||||
|
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||||
|
let Embed = this.client.util.embed()
|
||||||
|
.setColor('NAVY')
|
||||||
|
.setTitle('Role deleted')
|
||||||
|
.setDescription(`${role.name} got deleted!`)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (!creationLog) return channel.send(Embed);
|
||||||
|
|
||||||
|
Embed.setDescription(`${role.name} got deleted by ${creationLog.executor}`);
|
||||||
|
|
||||||
|
channel.send(Embed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = roleDeleteListener;
|
Loading…
Reference in a new issue