roleUpdate Logs Entires Roles List For A Small Change On One Role

Whenever I Change The Slightest Thing On A Role It Fires The Event And Logs ALL The Roles Is There A Way It Targets The Current Edited? This Is What I Have, & Would Like To Be-able To Log Permissions Again In The Embed To Completed My Role Update Logger
//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: [] });
});
//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: [] });
});
2 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Rarrorr
RarrorrOP9mo ago
how do i narrow it down to just the currently editied? that what i want to know over everything else they way i have it is the way i expected to be the intended outcome
Want results from more Discord servers?
Add your server