log bulk deletes in message log

This commit is contained in:
Jan 2022-05-22 19:39:07 +02:00
parent 587e35b44e
commit db88b94fee
2 changed files with 33 additions and 2 deletions

View file

@ -85,8 +85,12 @@ export default {
.catch(console.error); .catch(console.error);
setTimeout(async () => { setTimeout(async () => {
await replyMsg?.delete(); try {
if (!messages.find(m => m._id == message._id)) await message.delete(); await message.channel?.deleteMessages([
replyMsg!._id,
message._id,
]);
} catch(e) { console.error(e) }
}, 6000); }, 6000);
} catch(e) { } catch(e) {
console.error(e); console.error(e);

View file

@ -106,6 +106,33 @@ client.on('packet', async (packet) => {
console.error(e); console.error(e);
} }
} }
if (packet.type == 'BulkMessageDelete') {
const channel = client.channels.get(packet.channel);
if (!channel) return;
try {
let config = await dbs.SERVERS.findOne({ id: channel.server?._id });
if (config?.logs?.messageUpdate) {
let embed: LogMessage = {
title: `Bulk delete in in ${channel.server?.name}`,
description: `${packet.ids.length} messages deleted in ` +
`[#${channel.name}](/server/${channel.server_id}/channel/${channel._id})`,
fields: [],
color: '#ff392b',
overrides: {
discord: {
description: `${packet.ids.length} messages deleted in #${channel.name}`,
}
}
}
await sendLogMessage(config.logs.messageUpdate, embed);
}
} catch(e) {
console.error(e);
}
}
}); });
async function logModAction(type: 'warn'|'kick'|'ban'|'votekick', server: Server, mod: Member, target: string, reason: string|null, infractionID: string, extraText?: string): Promise<void> { async function logModAction(type: 'warn'|'kick'|'ban'|'votekick', server: Server, mod: Member, target: string, reason: string|null, infractionID: string, extraText?: string): Promise<void> {