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

Loading…
Cancel
Save