guildMemberUpdate, function not executing as expected

Node.js: v20.5.1
Discord.js: v14.13.0

https://hastebin.com/share/etonilifab.typescript

This function executes completely fine on the second, third and fourth execution. However, on the first it is unable to get oldMember, as it is not cached.
How would I be able to have it so that it allows for me to synchronise their roles correctly? I attempted to use partials yet this did not work as roles can be added yet not removed.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Was this page helpful?