From 783c3a013d9299f5505d0af464c6aad82ceca0d9 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 4 Dec 2021 16:47:43 +0000 Subject: [PATCH] Update messageDelete event to ignore bots --- events/messageUpdate.js | 37 ------------------------------------- src/events/MessageEvents.ts | 1 + 2 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 events/messageUpdate.js diff --git a/events/messageUpdate.js b/events/messageUpdate.js deleted file mode 100644 index 337bd25..0000000 --- a/events/messageUpdate.js +++ /dev/null @@ -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; diff --git a/src/events/MessageEvents.ts b/src/events/MessageEvents.ts index 0d449ec..29dfe8d 100644 --- a/src/events/MessageEvents.ts +++ b/src/events/MessageEvents.ts @@ -9,6 +9,7 @@ export default class MessageEvents extends Event { public override messageDelete(message: Message) { if (!message.guild) return; + if (message.author.bot) return; const embed = new EventEmbed(message.guild, "Message Deleted"); embed.AddUser("User", message.author, true);