//Check For Role Edits
client.on("roleUpdate", async (oldRole, newRole) => {
const guildID = oldRole.guild.id; // Grab GuildID From The Member Atrib
const loggedLoggingChannelId = await db.get(`loggedlogschannel_${guildID}`) || [];
const loggingChannelIdIndex = loggedLoggingChannelId.findIndex(entry => entry.name === "Channel");
let loggerChannelId;
if (loggingChannelIdIndex !== -1) {
loggerChannelId = loggedLoggingChannelId[loggingChannelIdIndex].value;
} else {
return;
}
//\n${ oldRole.permissions.toArray().join(', ') ? "No Permissions" : oldRole.permissions.toArray().join(', ') } \n${ newRole.permissions.toArray().join(', ') ? "No Permissions" : newRole.permissions.toArray().join(', ') } \n //Commented out as i thought this was the cause
let oldRoleColour = oldRole.color.toString(16).padStart(6, '0')
let newRoleColour = newRole.color.toString(16).padStart(6, '0')
const roleUpdateLoggerEmbed = new EmbedBuilder().setColor(teaGreen).setTitle(`A Role Has Been updated ${oldRole.name} [${oldRole.id}]`)
.addFields(
{ name: `Name Change?`, value: `${oldRole.name} -> ${newRole.name}` },
{ name: `Colour Change?`, value: `[#${oldRoleColour}](https://www.color-hex.com/color/${oldRoleColour} "Color-hex") -> [#${newRoleColour}](https://www.color-hex.com/color/${newRoleColour} "Color-hex")` },
{ name: `Is Displayed?`, value: `${oldRole.hoist ? "Role Is Displayed" : "Role Is Not Displayed"} -> ${newRole.hoist ? "Role Is Displayed" : "Role Is Not Displayed"}` },
{ name: `Posistion?`, value: `${oldRole.position ? `Role Position ${oldRole.position}` : `Role Position ${oldRole.position}`} -> ${newRole.position ? `Role Position ${newRole.position}` : `Role Position ${newRole.position}`}` },
{ name: `Mentionable?`, value: `${oldRole.mentionable ? `Role Mentionable ${oldRole.mentionable}` : `Role Mentionable ${oldRole.mentionable}`} -> ${newRole.mentionable ? `Role Mentionable ${newRole.mentionable}` : `Role Mentionable ${newRole.mentionable}`}` },
{ name: `This Guild's Name`, value: `${oldRole.guild}` },
).setFooter({ text: `The Role Position Is Based On 1 Being The Last Item On The List And 100 Being On The Top Of The List`, iconURL: client.user.displayAvatarURL({ dynamic: true }), inline: true }).setTimestamp()
await client.guilds.cache.get(guildID).channels.cache.get(loggerChannelId).send({ content: null, embeds: [roleUpdateLoggerEmbed], files: [] });
});