Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda