Update messageDelete event to ignore bots
This commit is contained in:
parent
598a0b5a44
commit
783c3a013d
2 changed files with 1 additions and 37 deletions
|
@ -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;
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue