Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda