blob: 5a9445eb3312a70da2034c5b8362d860e3b9a20e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { EmbedBuilder, Events, AttachmentBuilder } from 'discord.js';
import { guildSettings } from '../models/guild-settings.js';
export default {
name: Events.MessageBulkDelete,
async execute(msg, channel) {
try {
const guildSetting = await guildSettings.findOne({ where: { guildID: channel.guild.id } });
if (!guildSetting || !guildSetting.logChannelID) return;
const logEmbed = new EmbedBuilder()
.setAuthor({ name: 'AleeBot Logging', iconURL: channel.client.user.avatarURL() })
.setDescription(`A bulk of ${msg.size} messages were deleted in ${channel}`)
.setColor('#ff021b')
.setTimestamp();
let messages = [];
msg.forEach(message => {
messages.push(`[${message.createdAt.toUTCString()}]`);
messages.push(`${message.author.username} (${message.author.id})`);
messages.push(`Message (${message.id}): ${message.content}`);
messages.push('-----------------------------------');
});
const messageContent = messages.join('\n');
const attachment = new AttachmentBuilder(Buffer.from(messageContent, 'utf-8'), { name: 'messages.txt' });
let deleteMessage = channel.client.channels.cache.get(guildSetting.logChannelID);
if (!deleteMessage) return;
await deleteMessage.send({ embeds: [logEmbed], files: [attachment] });
} catch (e) {
console.error(e);
}
}
};
|