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

234
Visualizações
Take two variables from a message and put each into different parts

I'm trying to make a command in discord.js.

I want to make it where ?party (link or something here) requirements: be cool is typed and then it would say

@user has pinged for party Link: (link that was posted) requirements: be cool

I'm new to discord.js so I'm trying to learn. Thank You!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Well, prolly change you command to be something like:

?party (link) (be cool). Keep things simple :)

Then you could parse thru the contents of the command and separate out the link from the requirements, like so:

text = message.content;

// check if the text is a command for your bot
if (text.startsWith("?party")) {
  // convert the contents of the command to an array, by splitting the text at spaces
  // Also get the rid of the command itself (?party)
  commandContents = text.split(" ").slice(1);
  link = commandContents[0];
  requirements = commandContents.slice(1).join(" "); // join the requirements back by spaces.

  if (!link) {
    message.channel.send(" no link");
  } else if (!requirements) {
    message.channel.send(" no requirements");
  } else {
    message.channel.send(
      `<@${message.author.id}> has pinged for party\n \n Link: ${link}]\n\nRequirements:${requirements}\n\n@everyone`
    );
  }
}

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