adabugra
adabugra
DIdiscord.js - Imagine ❄
Created by adabugra on 12/25/2023 in #djs-questions
Weird roles issue
const { Events } = require('discord.js');

module.exports = {
name: Events.GuildMemberUpdate,
async execute(oldMember, newMember) {
try {
const guild = newMember.guild;
const fetchedMember = await guild.members.fetch(newMember.id);

if (oldMember.roles.cache.size !== fetchedMember.roles.cache.size) {
const addedRoles = fetchedMember.roles.cache.filter(role => !oldMember.roles.cache.has(role.id));

if (addedRoles.has('1188850631734206484')) {
fetchedMember.roles.remove('1150002502956236853')
.then(() => console.log(`Removed role 1150002502956236853 from ${fetchedMember.user.tag}`))
.catch(error => console.error(`Error removing role: ${error.message}`));
}
}
} catch (error) {
console.error(`Error fetching member: ${error.message}`);
}
},
};
const { Events } = require('discord.js');

module.exports = {
name: Events.GuildMemberUpdate,
async execute(oldMember, newMember) {
try {
const guild = newMember.guild;
const fetchedMember = await guild.members.fetch(newMember.id);

if (oldMember.roles.cache.size !== fetchedMember.roles.cache.size) {
const addedRoles = fetchedMember.roles.cache.filter(role => !oldMember.roles.cache.has(role.id));

if (addedRoles.has('1188850631734206484')) {
fetchedMember.roles.remove('1150002502956236853')
.then(() => console.log(`Removed role 1150002502956236853 from ${fetchedMember.user.tag}`))
.catch(error => console.error(`Error removing role: ${error.message}`));
}
}
} catch (error) {
console.error(`Error fetching member: ${error.message}`);
}
},
};
when i give the role with my hand bot removes the correct role, but when my verification bot gives it bot does nothing.
4 replies