I'm trying to create a command where if you say a slash command with a use parameter then it will give that user the role. I keep receiving this error even though I know that the member exists.
TypeError: Cannot read properties of undefined (reading 'roles')
My code:
const { commandName, options } = interaction;
const user = options.getUser('user');
if (commandName == 'givebetatester'){
console.log(user);
const role = interaction.guild.roles.cache.get('917609388154425374');
interaction.reply('Success');
user.member.roles.add(role);
}
I've double-checked that I have the role and the user exist and I have no idea what's wrong at this point. Any help would be appreciated.