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

71
Views
No message on buttonClick discord.js

When I click on button I get error "Interaction failed" This is full code I have written. What could be wrong here? I tried and interaction.create but no luck so far. Thank you.

Index.js

const { token } = require('./config.json');
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js');
const {gabriel} = require('./commands/gabriel.js')

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
  });

  client.on('messageCreate', message => {
    if(message.content === "$gabriel") {
        gabriel(message);
    }

});

client.on('clickButton', async (button) => {
  if(button.id === "11"){
    await button.reply.defer()
    await button.message.channel.send("Skills are posted in here!")
  } else if (button.id === "12"){
    await button.reply.defer()
    await button.message.channel.send("Constellation Data!")
  }
});

  client.login(token);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

First things first, there isn't an event called clickButton in discord.js unless you use extra npm packages such as discord.js-buttons. You can check the list of all the events at discord.js | Client. To execute a piece of code when a button is clicked, you would have to create a messageComponentCollector in the channel of your choice by doing:

var filter = (click) => click.user.id === message.author.id; // Creating a filter to only allow some users to click the button
const collector = message.channel.createMessageComponentCollector({
  time:
    1000 *
    10 /* Choosing how long the collector can work. (The time is in milliseconds) */,
  max: 1 /* Defining the maximum number of clicks on the button */,
  filter: filter /* Applying the filter */,
});
collector.on('collect', (click) => {
  // Execute some code
});
about 4 years ago · Juan Pablo Isaza Report

0

For discord.js v13, clickButton is not an event. You need to use onInteraction then check if the interaction is a button.

For example:

client.on('interaction' (interaction) => {
  if (interaction.isButton()) {
    // do stuff
  }
});
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!