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

142
Views
Discord.js Button on Embed

I would like to make this send an embed instead of it saying "If you want to apply, click the button below.", and have the apply button underneath the embed I have read up about some Component array and embed array stuff but I can't seem to get anything working with that If anyone could help me out id appreciate it ๐Ÿ™‚

Two very helpful people have helped me

@Skulaurun Mrusal and @PerplexingParadox

Thank you! ๐Ÿ™‚

enter image description here

client.on("message", async (message) => {
      // Don't reply to bots
  if (message.author.bot) return;

  if (message.content == "#req") {
         if(!message.member.hasPermission("MANAGE_MESSAGES"))
     {
        message.reply("You do not have permission to do that!");
        return;
     }
    // Perform raw API request and send a message with a button,
    // since it isn't supported natively in discord.js v12
    client.api.channels(message.channel.id).messages.post({
      data: {
        embeds: [reqEmbed],
        components: [
          {
            type: 1,
            components: [
              {
                type: 2,
                style:  4,
                label: "Apply",
                // Our button id, we can use that later to identify,
                // that the user has clicked this specific button
                custom_id: "send_application"
              }
            ]
          }
        ]
      }
    });
  }
});
about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

You only need to modify your code with one line. You just have to send your exampleEmbed through the Discord API post instead of using the discord.js method.

To do that, all you have to do is add an embeds field, which takes in an array of embed objects, which you have conveniently labeled as exampleEmbed, and put it there.

Like this:

client.api.channels(message.channel.id).messages.post({
    data: {
        //adds the embed here, so the button and embed will be sent together
        embeds: [exampleEmbed],
        components: [
            {
                type: 1,
                components: [
                    {
                        type: 2,
                        style: 1,
                        label: "Apply",
                        // Our button id, we can use that later to identify,
                        // that the user has clicked this specific button
                        custom_id: "send_application"
                    }
                ]
            }
        ],
    }
});

Here's the Discord API documentation for reference.


In addition, it seems like discord.js v13 also supports buttons as well, but since it's been released pretty recently, I haven't had time to check it out.

Discord.js Guide

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!