woomy/src/events/messageDelete.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-01-25 10:02:43 +00:00
const Discord = require("discord.js");
module.exports = (client, message) => {
if (message.author.bot) return;
const settings = (message.settings = client.getSettings(message.guild.id));
if (settings.chatlogsChannel !== "off") {
2020-03-09 01:11:33 +00:00
const channel = message.guild.channels.cache.find(
2020-01-25 10:02:43 +00:00
channel => channel.name === settings.chatlogsChannel
)
var msg = message.content;
if(!message.member) {
return;
}
if(msg.length + message.member.user.username.length + message.member.user.id.length + message.channel.name.length + 2 > 2048) {
return;
}
if (channel) {
2020-03-09 01:11:33 +00:00
let embed = new Discord.MessageEmbed();
2020-01-25 10:02:43 +00:00
embed.setColor("#f93a2f");
2020-03-09 01:11:33 +00:00
embed.setAuthor("Message deleted!", message.member.user.avatarURL({dynamic: true}));
2020-01-25 10:02:43 +00:00
if (msg == "") {
msg = "**An image was deleted, but is not shown for privacy reasons.**"
} else {
msg = `\`${msg}\``
}// image-only; maybe we can add image logging too but depends privacy (if someone sends like personal stuff accidentally)
embed.setDescription(` Author: ${message.member} (${message.member.user.id})\n Channel: ${message.channel}\n Message: ${msg}`)
try {
channel.send({ embed });
} catch (err) {
// probably no permissions to send messages/embeds there
};
};
};
};