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

93
Visualizações
I have a little problem with a certain command in discord.js

So I'm making a bot for myself to do stuff, and I tried to make a kill command

if (CMD_NAME == "kill") {
    let target = message.mentions.members.first()
    message.reply(`${target} is die`)
}

and I came to the conclusion that the bot doesn't know what is message.mentions.members.first() in general, how do I fix that? Also if I need to show more code, tell me

Edit: how I coded in the prefix:

    if (message.author.bot) return;
    if (message.content.startsWith(PREFIX)) {
        const [CMD_NAME, ...args] = message.content
        .trim()
        .substring(PREFIX.length)
        .split (/\/s+/)```
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Based on comments under your question, I think your problem might be somewhere else.

const PREFIX = "!"
let str = "!a b c"
const [CMD_NAME, ...args] = str.trim().substring(PREFIX.length).split(/\/s+/)
console.log(CMD_NAME)
console.log(args)

outputs:

a b c
[]

So it appears that your code is putting whole msg as "command name" which probably makes it fail name check and that's why nothing at all happens. Changing that split regex to /\s+/ to properly detect whitespaces changes the output to:

a
[ 'b', 'c' ]

which would probably fix your issue.

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