Im trying to make bot check status of users, when they have discord.gg/ or .gg/ on status give a role, and if they take it out remove it
client.on('presenceUpdate', async (oldPresence, newPresence) => {
const role = newPresence.guild.roles.cache.get('910192386267840513');
const member = newPresence.member;
const activities = member.user.presence.activities[0];
if (activities && (activities.state.includes('.gg/') || activities.state.includes('discord.gg/'))) {
return newPresence.member.roles.add(role);
}
else if (member.roles.cache.get(role.id)) {
newPresence.member.roles.remove(role);
}});
This is the error it shows
const activities = member.user.presence.activities[0];
^
TypeError: Cannot read properties of undefined (reading 'activities')
Users no longer have presences. You will need to use the GuildMember to get the presence
const activities = member.presence.activities[0]