For some reason the GuildMemberUpdate is not triggering when a user in the guild with the bot changes there avatar but it will trigger for everything else like username change and role remove/add,
Im not really sure why its not triggering if anyone has any ideas please let me know also on the dev portal the bot is configured with the Privileged Gateway Intents for GUILD_MEMBERS , Presence Update and message content. Im at a complete loss
const { token, databaseToken } = process.env;
const { connect } = require("mongoose");
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const fs = require("fs");
const chalk = require("chalk");
const https = require("https"); // Add this line
const WebSocket = require("ws");
const path = require("path");
const express = require("express");
const session = require("express-session");
//returns all GatewayIntentBits
// const client = new Client({
// intents: Object.keys(GatewayIntentBits).map((a) => GatewayIntentBits[a]),
// });
const client = new Client({
intents: [
GatewayIntentBits.Guilds, // Enables access to guild-related events
GatewayIntentBits.GuildMembers, // Enables access to guild member events
GatewayIntentBits.GuildModeration, // Enables access to guild ban events,
GatewayIntentBits.GuildEmojisAndStickers, // Enables access to guild emoji and sticker events
GatewayIntentBits.GuildIntegrations, // Enables access to guild integration events
GatewayIntentBits.GuildWebhooks, // Enables access to guild webhook events
GatewayIntentBits.GuildInvites, // Enables access to guild invite events
GatewayIntentBits.GuildVoiceStates, // Enables access to guild voice state events
GatewayIntentBits.GuildPresences, // Enables access to guild presence events
GatewayIntentBits.GuildMessages, // Enables access to guild message events
GatewayIntentBits.GuildMessageReactions, // Enables access to guild message reaction events
GatewayIntentBits.GuildMessageTyping, // Enables access to guild message typing events
GatewayIntentBits.DirectMessages, // Enables access to direct message events
GatewayIntentBits.DirectMessageReactions, // Enables access to direct message reaction events
GatewayIntentBits.DirectMessageTyping, // Enables access to direct message typing events
],
});
client.on("ready", () => {
client.guilds.cache.forEach(guild => guild.members.fetch());
client.guilds.cache.forEach(guild => {
guild.members.fetch().catch(console.error); // Ensures all members are cached
});
});
client.on("guildMemberUpdate", (oldMember, newMember) => {
console.log(`Old Member: ${oldMember.user.tag}`);
console.log(`New Member: ${newMember.user.tag}`);
const oldAvatar = oldMember.user.displayAvatarURL();
const newAvatar = newMember.user.displayAvatarURL();
console.log(`Old Avatar: ${oldAvatar}`);
console.log(`New Avatar: ${newAvatar}`);
if (oldAvatar !== newAvatar) {
console.log(`Avatar changed for ${newMember.user.tag}`);
} else {
console.log(`No avatar change detected for ${newMember.user.tag}`);
}
});
client.on("guildMemberUpdate", async (oldMember, newMember) => {
const fetchedMember = await newMember.guild.members.fetch(newMember.id);
const oldAvatar = oldMember.user.displayAvatarURL();
const newAvatar = fetchedMember.user.displayAvatarURL();
if (oldAvatar !== newAvatar) {
console.log(`Avatar changed for ${newMember.user.tag}`);
}
});```
i have tryied to pre cashe all the users in the guilds with
`client.on("ready", () => {
client.guilds.cache.forEach(guild => guild.members.fetch());
client.guilds.cache.forEach(guild => {
guild.members.fetch().catch(console.error); // Ensures all members are cached
});
});`
im at a complete loss i have even asked chat gpt but it doesn't know either
You need to sign in to view this answers
Leave feedback about this