Browse Source

Fix null errors for message deletes

master
Abheek Dhawan 4 years ago
parent
commit
746ae2e56d
  1. 21
      index.js

21
index.js

@ -18,12 +18,21 @@ client.on("guildMemberAdd", member => {
}); });
client.on('messageDelete', message => { client.on('messageDelete', message => {
const messageContent = message.content;
const messageAvatar = message.author.avatarURL();
const messageID = message.id;
let messageAuthor;
if (message.author) {
messageAuthor = message.author.tag;
} else {
messageAuthor = "Someone else deleted this message"
}
const deleteEmbed = new Discord.MessageEmbed() const deleteEmbed = new Discord.MessageEmbed()
.setTitle('Message Deleted') .setTitle('Message Deleted')
.addField('Author', message.author.tag) .addField('Author', messageAuthor)
.addField('Message', message.content) .addField('Message', messageContent)
.setThumbnail(message.author.avatarURL()) .setThumbnail(messageAvatar)
.setFooter("ID: " + message.id) .setFooter("ID: " + messageID)
.setTimestamp() .setTimestamp()
.setColor('ff0000'); .setColor('ff0000');
client.guilds.cache.get("826506878976000030").channels.cache.get("826876551756513314").send(deleteEmbed).catch(console.error); client.guilds.cache.get("826506878976000030").channels.cache.get("826876551756513314").send(deleteEmbed).catch(console.error);
@ -48,6 +57,7 @@ client.on('channelCreate', channel => {
if (channel.guild.id = "826506878976000030") { if (channel.guild.id = "826506878976000030") {
const channelName = channel.name; const channelName = channel.name;
const channelID = channel.id; const channelID = channel.id;
const channelType = channel.type;
let channelCategory; let channelCategory;
if (channel.parent) { if (channel.parent) {
channelCategory = channel.parent.name; channelCategory = channel.parent.name;
@ -55,8 +65,9 @@ client.on('channelCreate', channel => {
channelCategory = "None"; channelCategory = "None";
} }
const channelCreateEmbed = new Discord.MessageEmbed() const channelCreateEmbed = new Discord.MessageEmbed()
.setTitle("#️⃣Channel Created") .setTitle("Channel Created")
.addField("Name", channelName) .addField("Name", channelName)
.addField("Type", channelType)
.addField("Category", channelCategory) .addField("Category", channelCategory)
.setFooter("ID: " + channelID) .setFooter("ID: " + channelID)
.setTimestamp() .setTimestamp()

Loading…
Cancel
Save