From 9b9667dbefed8051eefe9c9ce46f5d3b2508bb50 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 2 Apr 2021 16:02:57 -0500 Subject: [PATCH] Add roleDelete and roleUpdate --- index.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 041cc64..2b81f4a 100644 --- a/index.js +++ b/index.js @@ -400,7 +400,7 @@ client.on('messageReactionRemove', (messageReaction, user) => { }); client.on('roleCreate', role => { - const messageReactionRemoveEmbed = new Discord.MessageEmbed() + const roleCreateEmbed = new Discord.MessageEmbed() .setTitle("Role Added") .addField("Name", role.name) .addField("Permissions", role.permissions.bitfield) @@ -408,6 +408,26 @@ client.on('roleCreate', role => { .setFooter("Role ID: " + role.id) .setTimestamp() .setColor(role.color); + collection.findOne({ guild_id: role.guild.id}, (error, result) => { + if(error) { + console.error; + } + botLogsChannel = result.bot_logs_id; + if (role.guild.channels.cache.get(botLogsChannel)) { + role.guild.channels.cache.get(botLogsChannel).send(roleCreateEmbed).catch(console.error); + } + }); +}); + +client.on('roleDelete', role => { + const roleDeleteEmbed = new Discord.MessageEmbed() + .setTitle("Role Removed") + .addField("Name", role.name) + .addField("Permissions", role.permissions.bitfield) + .addField("Mentionable", role.mentionable) + .setFooter("Role ID: " + role.id) + .setTimestamp() + .setColor(role.color); collection.findOne({ guild_id: role.guild.id}, (error, result) => { if(error) { console.error; @@ -419,6 +439,26 @@ client.on('roleCreate', role => { }); }); +client.on('roleUpdate', (oldRole, newRole) => { + const messageReactionRemoveEmbed = new Discord.MessageEmbed() + .setTitle("Role Added") + .addField("Name", `${oldRole.name} >> ${newRole.name}`) + .addField("Permissions", `${oldRole.permissions.bitfield} >> ${newRole.permissions.bitfield}`) + .addField("Mentionable", `${oldRole.mentionable} >> ${newRole.mentionable}`) + .setFooter("Role ID: " + newRole.id) + .setTimestamp() + .setColor(newRole.color); + collection.findOne({ guild_id: newRole.guild.id}, (error, result) => { + if(error) { + console.error; + } + botLogsChannel = result.bot_logs_id; + if (newRole.guild.channels.cache.get(botLogsChannel)) { + newRole.guild.channels.cache.get(botLogsChannel).send(messageReactionRemoveEmbed).catch(console.error); + } + }); +}); + /*client.on('userUpdate', (oldUser, newUser) => { if (oldUser.bot) { return;