You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Natsuki/events/messageDelete.js

29 lines
1.8 KiB

const Discord = require('discord.js');
3 years ago
const channelTypes = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE"];
module.exports = async (client, message) => {
3 years ago
if (!channelTypes.includes(message.channel.type)) {return;}
//if (!Object.keys(snipe.delete).includes(message.guild.id)) {snipe.delete[message.guild.id] = {};};
//snipe.delete[message.guild.id][message.channel.id] = message;
let ts = client.guildconfig.logs.has(message.guild.id) && client.guildconfig.logs.get(message.guild.id).has('mdelete') ? client.guildconfig.logs.get(message.guild.id).get('mdelete') : null;
if (ts) {if (message.guild.channels.cache.has(ts) && message.guild.channels.cache.get(ts).permissionsFor(client.user.id).has("SEND_MESSAGES")) {
let mde = new Discord.MessageEmbed()
.setTitle('Message Deleted')
.setDescription(`Sent by <@${message.author.id}> | In <#${message.channel.id}>`)
.setThumbnail(message.author.avatarURL({size: 1024}))
.setColor('ecff8f').setFooter("Natsuki", client.user.avatarURL()).setTimestamp();
if (message.content && message.content.length) {mde.addField("Message", "`-> `" + message.content.toString());}
if (message.attachments.size) {
if (message.attachments.first().url.includes(".png") || message.attachments.first().url.includes(".jpg") || message.attachments.first().url.includes(".gif")) {/*console.log('e');*/ try {mde.setImage(message.attachments.first().url);} catch {}}
let av = Array.from(message.attachments.values());
let as = ''; for (let a of av) {
as += `[Att. ${av.indexOf(a) + 1}](${a.url})`;
if (av.indexOf(a) + 1 < av.length) {as += ' | ';}
}
if (as.length) {mde.addField('Attachments', as);}
}
3 years ago
message.guild.channels.cache.get(ts).send({embeds: [mde]}).catch(() => {});
}}
}