I am trying to only allow someone to do things if their permissions are correct, and currently it is just giving me this error:
TypeError: Cannot read properties of undefined (reading 'has')
Here is my code:
// @ts-check
const { SlashCommandBuilder } = require('@discordjs/builders');
const userParam = "user"
module.exports = {
data: new SlashCommandBuilder()
.setName('checkuserskins')
.setDescription(`Check's the selected user's custom skin inventory.`)
.addUserOption(option =>
option.setName("user")
.setDescription('The user to check')
.setRequired(true)
),
async execute(interaction) {
const user = interaction.options.getUser('user');
if (!user) {
return interaction.reply({ content: `Could not find user ${user}`, ephemeral: true });
}
if (!interaction.user.roles.has("937401230316159076") || interaction.user.id !== user.id) {
return interaction.reply({ content: `You don't have permission to do that!`, ephemeral: true });
}
return interaction.reply();
},
};
Thanks.