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

255
Vistas
how to use variables as input for embed message? Discord.js

I got a question how to use a variable as a input for an embed message. When somebody message: asl hey @somebody 123, I want that the bot sends a embed message with the information given. I already made a script that haves args, so messageA{arg1} etc but now i want to use it in the embed message.

I tried this:

  if(msg.content === "test9") {
    const examplesEmbed = new MessageEmbed()
    const args = msg.content.trim().split(/ +/g);
      let bericht = args[0]; // Remember arrays are 0-based!.
      let noemen = args[1];
      let pers = args[2]
    
  .setTitle('Info about your request')
    .setAuthor({ name: 'Jordy'})
    .setDescription('Self-made bot "by jordy" self scripted etc. Yes even this :')
    .addFields(
        { name: 'Regular field title', value: bericht},
        { name: '\u200B', value: '\u200B' },
        { name: 'Inline field title', value: 'Some value here', inline: true },
    )
    .addField('Inline field title', 'Some value here', true)
    .setImage('https://i.imgur.com/AfFp7pu.png')
    .setTimestamp()
    .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
  msg.channel.send({ embeds: [examplesEmbed] });
  }
})


In an other script its the A has value for ' hello' but I get an error. how do I fix this?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The solution to this is quite simple, in order to use variables within strings in JS, you must use backticks (`).

You can use either of the following instead:

    { name: 'Regular field title', value: `${messageA}` },
    { name: 'Regular field title', value: messageA },
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