102 lines
2.5 KiB
JavaScript
102 lines
2.5 KiB
JavaScript
|
const { Observer } = require('../../../interfaces/');
|
||
|
|
||
|
const CONSTANTS = {};
|
||
|
|
||
|
class GuildLogger extends Observer {
|
||
|
|
||
|
constructor(client) {
|
||
|
|
||
|
super(client, {
|
||
|
name: 'guildLogger',
|
||
|
priority: 3
|
||
|
});
|
||
|
|
||
|
this.hooks = [
|
||
|
['message', this.storeAttachment.bind(this)], //Attachment logging
|
||
|
['messageDelete', this.messageDelete.bind(this)],
|
||
|
['messageDeleteBulk', this.messageDeleteBulk.bind(this)],
|
||
|
['messageUpdate', this.messageEdit.bind(this)],
|
||
|
['voiceStateUpdate', this.voiceState.bind(this)],
|
||
|
['guildBanAdd', this.ban.bind(this)],
|
||
|
['guildBanRemove', this.unban.bind(this)],
|
||
|
['guildMemberAdd', this.memberJoin.bind(this)],
|
||
|
['guildMemberRemove', this.memberLeave.bind(this)],
|
||
|
['guildMemberUpdate', this.memberUpdate.bind(this)]
|
||
|
];
|
||
|
|
||
|
}
|
||
|
|
||
|
async storeAttachment(message) {
|
||
|
|
||
|
}
|
||
|
|
||
|
//TODO: Figure this thing out, this should be called from messageDelete and rawMessageDelete if any attachments are present
|
||
|
//data should be an object containing the necessary information to query for the attachment from the db, and the relevant information to log it
|
||
|
//Will figure this out once I get to that point
|
||
|
async logAttachment(data) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async messageDelete(message) {
|
||
|
|
||
|
const { guild } = message;
|
||
|
if (!guild) return;
|
||
|
|
||
|
if (!message.member) message.member = await guild.members.fetch(message.author);
|
||
|
const { member, channel } = message;
|
||
|
|
||
|
const settings = await guild.settings();
|
||
|
const chatlogs = settings.messageLog;
|
||
|
if (!chatlogs || !chatlogs.channel) return;
|
||
|
|
||
|
const { ignoredRoles, ignoredChannels } = chatlogs;
|
||
|
const logChannel = guild.resolveChannel(chatlogs.channel);
|
||
|
if (!logChannel) return;
|
||
|
|
||
|
if (ignoredRoles && member._roles.length)
|
||
|
for (const role of ignoredRoles)
|
||
|
if (member._roles.includes(role)) return;
|
||
|
|
||
|
if (ignoredChannels && ignoredChannels.includes(channel.id)) return;
|
||
|
|
||
|
if (message.attachments.size) return this.logAttachment();
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
async messageDeleteBulk(messages) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async messageEdit(oldMessage, newMessage) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async voiceState(oldState, newState) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async ban(guild, user) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async unban(guild, user) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async memberJoin(member) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async memberLeave(member) {
|
||
|
|
||
|
}
|
||
|
|
||
|
async memberUpdate(oldMember, newMember) {
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = GuildLogger;
|