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

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

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 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