forked from Supositware/Haha-Yes
Some more logging options
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
66314b5c79
commit
3d8f20f054
6 changed files with 122 additions and 3 deletions
|
@ -12,6 +12,13 @@ class channelCreateListener extends Listener {
|
|||
async exec(GuildChannel) {
|
||||
const logStats = await LogStats.findOne({where: {guild: GuildChannel.guild.id}});
|
||||
if (logStats) {
|
||||
const fetchedLogs = await GuildChannel.guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'CHANNEL_CREATE',
|
||||
});
|
||||
|
||||
const creationLog = fetchedLogs.entries.first();
|
||||
|
||||
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||
let Embed = this.client.util.embed()
|
||||
.setColor('NAVY')
|
||||
|
@ -20,6 +27,10 @@ class channelCreateListener extends Listener {
|
|||
.setFooter(`Channel ID: ${GuildChannel.id}`)
|
||||
.setTimestamp();
|
||||
|
||||
if (!creationLog) return channel.send(Embed);
|
||||
|
||||
Embed.setDescription(`${GuildChannel.type} channel ${GuildChannel} got created by ${creationLog.executor}`);
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,24 @@ class channelDeleteListener extends Listener {
|
|||
async exec(GuildChannel) {
|
||||
const logStats = await LogStats.findOne({where: {guild: GuildChannel.guild.id}});
|
||||
if (logStats) {
|
||||
const fetchedLogs = await GuildChannel.guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'CHANNEL_DELETE',
|
||||
});
|
||||
|
||||
const deletionLog = fetchedLogs.entries.first();
|
||||
|
||||
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||
let Embed = this.client.util.embed()
|
||||
.setColor('NAVY')
|
||||
.setTitle('Channel created!')
|
||||
.setDescription(`${GuildChannel.type} channel ${GuildChannel.name} got deleted!`)
|
||||
.setDescription(`${GuildChannel.type} channel ${GuildChannel} got deleted!`)
|
||||
.setTimestamp();
|
||||
|
||||
if (!deletionLog) return channel.send(Embed);
|
||||
|
||||
Embed.setDescription(`${GuildChannel.type} channel ${GuildChannel} got deleted by ${deletionLog.executor}`);
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,17 @@ class channelUpdateListener extends Listener {
|
|||
const logStats = await LogStats.findOne({where: {guild: newChannel.guild.id}});
|
||||
|
||||
if (logStats) {
|
||||
const fetchedLogs = await newChannel.guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'CHANNEL_CREATE',
|
||||
});
|
||||
|
||||
const updateLog = fetchedLogs.entries.first();
|
||||
|
||||
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||
let Embed = this.client.util.embed()
|
||||
.setColor('NAVY')
|
||||
.setTitle(`${newChannel.type} channel updated!`)
|
||||
.setDescription(`**${newChannel} channel updated!**`)
|
||||
.setTimestamp();
|
||||
|
||||
if (oldChannel.name !== newChannel.name) {
|
||||
|
@ -39,6 +46,10 @@ class channelUpdateListener extends Listener {
|
|||
.addField('New channel slowmode', `${newChannel.rateLimitPerUser} seconds`, true);
|
||||
}
|
||||
|
||||
if (!updateLog) return channel.send(Embed);
|
||||
|
||||
Embed.setDescription(`**${newChannel} channel updated by ${updateLog.executor}**`);
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
|
|
37
event/listeners/log/guildBanAdd.js
Normal file
37
event/listeners/log/guildBanAdd.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const { Listener } = require('discord-akairo');
|
||||
const LogStats = require('../../../models/').LogStats;
|
||||
|
||||
class guildBanAddListener extends Listener {
|
||||
constructor() {
|
||||
super('guildBanAdd', {
|
||||
emitter: 'client',
|
||||
event: 'guildBanAdd'
|
||||
});
|
||||
}
|
||||
|
||||
async exec(guild, user) {
|
||||
const logStats = await LogStats.findOne({where: {guild: guild.id}});
|
||||
if (logStats) {
|
||||
const fetchedLogs = await guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'MEMBER_BAN_ADD',
|
||||
});
|
||||
|
||||
const banLog = fetchedLogs.entries.first();
|
||||
|
||||
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||
let Embed = this.client.util.embed()
|
||||
.setColor('NAVY')
|
||||
.setTitle('A user got banned!')
|
||||
.setDescription(`${user.tag} got banned!`)
|
||||
.setTimestamp();
|
||||
|
||||
if (!banLog) return channel.send(Embed);
|
||||
|
||||
Embed.setDescription(`${user.tag} got banned by ${banLog.executor}`);
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = guildBanAddListener;
|
37
event/listeners/log/guildBanRemove.js
Normal file
37
event/listeners/log/guildBanRemove.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const { Listener } = require('discord-akairo');
|
||||
const LogStats = require('../../../models/').LogStats;
|
||||
|
||||
class guildBanRemoveListener extends Listener {
|
||||
constructor() {
|
||||
super('guildBanRemove', {
|
||||
emitter: 'client',
|
||||
event: 'guildBanRemove'
|
||||
});
|
||||
}
|
||||
|
||||
async exec(guild, user) {
|
||||
const logStats = await LogStats.findOne({where: {guild: guild.id}});
|
||||
if (logStats) {
|
||||
const fetchedLogs = await guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'MEMBER_BAN_REMOVE',
|
||||
});
|
||||
|
||||
const unbanLog = fetchedLogs.entries.first();
|
||||
|
||||
const channel = this.client.channels.resolve(await logStats.get('channel'));
|
||||
let Embed = this.client.util.embed()
|
||||
.setColor('NAVY')
|
||||
.setTitle('A user got unbanned!')
|
||||
.setDescription(`${user.tag} got unbanned!`)
|
||||
.setTimestamp();
|
||||
|
||||
if (!unbanLog) return channel.send(Embed);
|
||||
|
||||
Embed.setDescription(`${user.tag} got unbanned by ${unbanLog.executor}`);
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = guildBanRemoveListener;
|
|
@ -12,15 +12,27 @@ class messageDeleteListener extends Listener {
|
|||
async exec(message) {
|
||||
const logStats = await LogStats.findOne({where: {guild: message.guild.id}});
|
||||
if (logStats) {
|
||||
const fetchedLogs = await message.guild.fetchAuditLogs({
|
||||
limit: 1,
|
||||
type: 'MESSAGE_DELETE',
|
||||
});
|
||||
|
||||
const deletionLog = fetchedLogs.entries.first();
|
||||
|
||||
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}`)
|
||||
.setDescription(`**${message.author} deleted their message in ${message.channel}**`)
|
||||
.setDescription(`**${message.author} message got deleted in ${message.channel}**`)
|
||||
.addField('Message deleted', message)
|
||||
.setFooter(`Author ID: ${message.author.id}`)
|
||||
.setTimestamp();
|
||||
|
||||
if (!deletionLog) return channel.send(Embed);
|
||||
else if (deletionLog.target === message.author) {
|
||||
Embed.setDescription(`**${message.author} message was deleted by ${deletionLog.executor} in ${message.channel}**`);
|
||||
}
|
||||
|
||||
channel.send(Embed);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue