Update messageDelete event to ignore bots #79

Merged
Vylpes merged 1 commit from bug/16-event-doesnt-ignore-bots into develop 2021-12-04 16:51:51 +00:00
2 changed files with 1 additions and 37 deletions

View file

@ -1,37 +0,0 @@
// Required components
const { event } = require('vylbot-core');
const { MessageEmbed } = require('discord.js');
// Event variables
const embedColor = "0x3050ba";
const logchannel = "message-logs";
// Event class
class messageupdate extends event {
constructor() {
// Set the event's run method
super("messageupdate");
}
// Run method
messageupdate(oldMessage, newMessage) {
// If the user is a bot or the content didn't change, return
if (newMessage.author.bot) return;
if (oldMessage.content == newMessage.content) return;
// Create an embed with the message's information
const embed = new MessageEmbed()
.setTitle("Message Edited")
.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 }));
// Send the embed into the log channel
newMessage.guild.channels.cache.find(channel => channel.name == logchannel).send(embed);
}
}
module.exports = messageupdate;

View file

@ -9,6 +9,7 @@ export default class MessageEvents extends Event {
public override messageDelete(message: Message) { public override messageDelete(message: Message) {
if (!message.guild) return; if (!message.guild) return;
if (message.author.bot) return;
const embed = new EventEmbed(message.guild, "Message Deleted"); const embed = new EventEmbed(message.guild, "Message Deleted");
embed.AddUser("User", message.author, true); embed.AddUser("User", message.author, true);