Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!