From d94eff8ece0ff0f2b8917b61f9d0decf54934923 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Wed, 23 Nov 2022 00:00:47 +1100 Subject: [PATCH] improve roleUpdate event a bit better. --- src/config.json | 2 +- src/events/roleUpdate.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/config.json b/src/config.json index 0d19b20..76b6c38 100644 --- a/src/config.json +++ b/src/config.json @@ -10,7 +10,7 @@ "commands": false, "logs": true, "automod": false, - "mpstats": true, + "mpstats": false, "mpstatsDebug": false, "autores": false }, diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts index d495cda..98fc0f8 100644 --- a/src/events/roleUpdate.ts +++ b/src/events/roleUpdate.ts @@ -11,11 +11,19 @@ export default { if (!roleLog) return const {executor, target} = roleLog; if (target) { - const embed = new client.embed().setColor(newRole.hexColor).setTimestamp().setTitle(`Role modified: ${oldRole.name}`).setDescription(`🔹 **Role**\n${target}\n\`${target.id}\``).addFields( - {name: `${executor.bot ? '🔹 Bot' : '🔹 Admin'}`, value: `<@${executor.id}>\n\`${executor.id}\``}, - {name: '🔹 Role changes', value: `**Old color:** ${oldRole.hexColor}\n**New color:** ${newRole.hexColor}`} + const embed = new client.embed().setColor(newRole.hexColor).setThumbnail(newRole?.iconURL()).setTimestamp().setTitle(`Role modified: ${newRole.name}`).setDescription(`🔹 **Role**\n${target}\n\`${target.id}\``).addFields( + {name: `${executor.bot ? '🔹 Bot' : '🔹 Admin'}`, value: `<@${executor.id}>\n\`${executor.id}\``} ); (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) + // Moved addFields to these below cuz yes for each role changes, it seems inefficent to me but it will do. :) + // Permissions field seems to trigger when role is hoisted/unhoisted atleast to me. + if (oldRole.hexColor !== newRole.hexColor) { + embed.addFields({name: '🔹 Role changes', value: `**Old color:** ${oldRole.hexColor}\n**New color:** ${newRole.hexColor}`}) + } else if (oldRole.name !== newRole.name) { + embed.addFields({name: '🔹 Role changes', value: `**Old name:** ${oldRole.name}\n**New name:** ${newRole.name}`}) + } else if (oldRole.permissions !== newRole.permissions) { + embed.addFields({name: '🔹 Role changes', value: `**Old permission(s):** ${newRole.permissions.missing(oldRole.permissions)}\n**New permission(s):** ${oldRole.permissions.missing(newRole.permissions)}`}) + } } else { console.log(`${target.id} was modified from ${client.guilds.cache.get(oldRole.guild.name)} but no audit log could be fetched.`) }