I want to make one command only for admins.
//comando nick
if(comando === 'nick'){
if (message.author.permissions.has(!Permissions.STAGE_MODERATOR)) return message.reply('No Perms!');
else{
if(args == ''){
message.channel.send(`my message`);
}
else{
message.guild.members.cache.get(client.user.id).setNickname(`${args}`);
message.channel.send(`my message`);
}
}
}
but i'm having this issue:
if (message.author.permissions.has(!Permissions.STAGE_MODERATOR)) return message.reply('No Perms!');
TypeError: Cannot read properties of undefined (reading 'has')
I taken this code in Discord Js docs, but isn't working 😢
permissions doesn't exist on type User which is what Message#author returns. Use Message#member which returns a GuildMember
if (message.member.permissions.has(!Permissions.STAGE_MODERATOR)) return message.reply('No Perms!')
Also note that you are using the logical NOT operator (!) wrong. Put it at the start of the if statement rather than as the permission (!Permissions.STAGE_MODERATOR is false)
if (!message.member.permissions.has(Permissions.STAGE_MODERATOR)) return message.reply('No Perms!')