Add messageDelete and messageUpdate events

This commit is contained in:
Vylpes 2020-11-04 12:22:54 +00:00
parent 89dac73ab3
commit edb307d6af
3 changed files with 55 additions and 0 deletions

25
events/messageDelete.js Normal file
View file

@ -0,0 +1,25 @@
const { event } = require('vylbot-core');
const { MessageEmbed } = require('discord.js');
const embedColor = "0x3050ba";
const logchannel = "logs";
class messagedelete extends event {
constructor() {
super("messagedelete");
}
messagedelete(message) {
let embed = new MessageEmbed()
.setTitle("Message Deleted")
.setColor(embedColor)
.addField("User", `${message.author} \`${message.author.tag}\``)
.addField("Channel", message.channel)
.addField("Content", `\`\`\`${message.content || "*none*"}\`\`\``)
.setThumbnail(message.author.displayAvatarURL({ type: 'png', dynamic: true }));
message.guild.channels.cache.find(channel => channel.name == logchannel).send(embed);
}
}
module.exports = messagedelete;

29
events/messageUpdate.js Normal file
View file

@ -0,0 +1,29 @@
const { event } = require('vylbot-core');
const { MessageEmbed } = require('discord.js');
const embedColor = "0x3050ba";
const logchannel = "logs";
class messageupdate extends event {
constructor() {
super("messageupdate");
}
messageupdate(oldMessage, newMessage) {
if (newMessage.author.bot) return;
if (oldMessage.content == newMessage.content) return;
let embed = new MessageEmbed()
.setTitle("Message Embed")
.setColor(embedColor)
.addField("User", `${newMessage.author} \`${newMessage.author.tag}\``)
.addField("Channel", newMessage.channel)
.addField("Before", `\`\`\`${oldMessage.content || "*none*"}\`\`\``)
.addField("After", `\`\`\`${newMessage.content || "*none*"}\`\`\``)
.setThumbnail(newMessage.author.displayAvatarURL({ type: 'png', dynamic: true }));
newMessage.guild.channels.cache.find(channel => channel.name == logchannel).send(embed);
}
}
module.exports = messageupdate;

View file

@ -4,6 +4,7 @@
"description": "", "description": "",
"main": "bot.js", "main": "bot.js",
"scripts": { "scripts": {
"start": "node bot.js",
"test": "echo \"No tests specified\"" "test": "echo \"No tests specified\""
}, },
"repository": { "repository": {