Is there a way to get a log of added or removed roles for a member?
I have used this code for a long time to achieve this until suddenly I encountered an error when a member is not in the cache. When the
guildMemberUpdate
event occurs, it logs that all roles the member already had have been added again.
Here is an example of the logs with this code, showing this issue:
where 418586876899885056
is the ID of the server (guild).5 Replies
- 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!You can fetch it from audit log
documentation suggestion for @XtoManuel:
:method: Guild#fetchAuditLogs()
@14.15.3
Fetches audit logs for this guild.
Discord.js version:
14.14.1
I have tried using Audit Logs, but the roles I want to log are primarily roles that are assigned automatically by Discord, such as the server Booster role, and roles from streaming or video platform subscriptions (Twitch/YouTube). These roles are not recorded in the Audit Logs.