From e99775912a01267690bac9ef1b83f491cb3600c6 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 2 Apr 2021 15:06:36 -0500 Subject: [PATCH] Add log for userUpdate --- index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/index.js b/index.js index 39fad9f..d2638a8 100644 --- a/index.js +++ b/index.js @@ -331,4 +331,34 @@ client.on('channelCreate', channel => { }); }); +client.on('userUpdate', (oldUser, newUser) => { + if (oldUser.bot) { + return; + } + const oldUserTag = oldUser.tag; + const newUserTag = newUser.tag; + const oldUserStatus = oldUser.presence.status; + const newUserStatus = newUser.presence.status; + const oldAvatarURL = oldUser.avatarURL(); + const newAvatarURL = newUser.avatarURL(); + + const userUpdateEmbed = new Discord.MessageEmbed() + .setTitle("Channel Created") + .addField("Tag", `${oldUserTag} >> ${newUserTag}`) + .addField("Status", `${oldUserStatus} >> ${newUserStatus}`) + .setThumbnail(oldAvatarURL) + .setImage(newAvatarURL) + .setTimestamp() + .setColor('00aaff'); + collection.findOne({ guild_id: channel.guild.id}, (error, result) => { + if(error) { + console.error; + } + botLogsChannel = result.bot_logs_id; + if (channel.guild.channels.cache.get(botLogsChannel)) { + channel.guild.channels.cache.get(botLogsChannel).send(userUpdateEmbed).catch(console.error); + } + }); +}); + client.login(process.env.BOT_TOKEN);