Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
Make a command in Discordjs that only executes if the member is admin

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 😢

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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!')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!