Browse Source

Fix messageDelete and improve messageUpdate logs

master
Abheek Dhawan 4 years ago
parent
commit
a124e2c7eb
  1. 19
      bot.js

19
bot.js

@ -657,15 +657,13 @@ async function bulkDelete(message) {
}).catch(console.error);
}
client.on('messageDelete', msg => {
msg.channel.messages.fetch(msg.id)
.then(message => {
client.on('messageDelete', message => {
const deleteEmbed = new Discord.MessageEmbed()
.setTitle('Message Deleted')
.setAuthor(message.author.tag, message.author.avatarURL())
.setURL(message.url)
.addField('Author', message.author.tag)
.addField('Message', message.content)
.setAuthor(message.author ? message.author.tag : "Unknown", message.author ? message.author.avatarURL() : client.user.defaultAvatarURL)
.addField('Author', message.author ? message.author.tag : "Message not cached")
.addField('Message', message.content ? message.content : "Message not cached")
.setThumbnail(message.author.avatarURL())
.setFooter("ID: " + message.id)
.setTimestamp()
@ -683,7 +681,6 @@ client.on('messageDelete', msg => {
}
});
});
});
client.on('messageDeleteBulk', messages => {
const numMessages = messages.array().length;
@ -709,10 +706,8 @@ client.on('messageDeleteBulk', messages => {
});
client.on('messageUpdate', (originalMessage, editedMessage) => {
if (editedMessage.author) {
if (editedMessage.author.bot) {
return;
}
message.channel.messages.fetch(editedMessage.id)
.then(editedMessage => {
const editEmbed = new Discord.MessageEmbed()
.setTitle("Message Edited")
.setURL(editedMessage.url)
@ -733,7 +728,7 @@ client.on('messageUpdate', (originalMessage, editedMessage) => {
}
}
});
}
});
});
client.on('channelCreate', channel => {

Loading…
Cancel
Save