const { Events } = require('discord.js');
module.exports = {
name: Events.GuildMemberUpdate,
async execute(oldMember, newMember) {
try {
// Fetch the full member from the guild
const guild = newMember.guild;
// Check if the member's roles have been updated
if (oldMember.roles.cache.size !== newMember.roles.cache.size) {
const addedRoles = newMember.roles.cache.filter(role => !oldMember.roles.cache.has(role.id));
// Check if the added roles include the role to be removed
if (addedRoles.has('1188850631734206484')) {
// Remove the specified role
newMember.roles.remove('1150002502956236853')
.then(() => console.log(`Removed role 1150002502956236853 from ${newMember.user.tag}`))
.catch(error => console.error(`Error removing role: ${error.message}`));
}
}
} catch (error) {
console.error(`Error fetching member: ${error.message}`);
}
},
};