Im trying to detect if a user has updated their profile picture. But it seems im completely stuck right now
I have tried to look for a solution but Ive found nothing
does anyone here know how to detect a pfp change ?
Here are my particals
partials: ['CHANNEL', 'GUILD_MEMBER', 'GUILD_SCHEDULED_EVENT', 'MESSAGE', 'REACTION', 'USER']
CodePudding user response:
You can use guildMemberUpdate event.
https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-guildMemberUpdate
client.on("guildMemberUpdate", async (oldMember, newMember) => {
if (oldMember.avatarURL() === newMember.avatarURL()) {
console.log("User didn't changed avatar");
} else {
console.log(`User changed avatar`);
};
});
When you use the guildMemberUpdate event, it only works if the person changes their avatar for the server. If you don't want it to be server specific, you should use the userUpdate event.
client.on("userUpdate", async (oldUser, newUser) => {
if (oldUser.avatarURL() === newUser.avatarURL()) {
console.log("User didn't changed avatar");
} else {
console.log(`User changed avatar`);
};
});