question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: ButtonComponent without id was not produced

See original GitHub issue

What happened?

 @ButtonComponent()
  mybtn(interaction: ButtonInteraction) {
    console.log('processing')
    if (interaction.customId === 'hello-btn') {
      interaction.reply(`👋 ${interaction.member}`);
    }
  }

Was not produced

Reproduction

client.on("interactionCreate", (interaction: Interaction) => {
  if (interaction.isButton()) {
    console.log(interaction.customId)
  }
  client.executeInteraction(interaction);
});

^ there customId will be logged

@Discord()
class buttonExample {
  @Slash("hello")
  async hello(
    @SlashOption("user", { required: true, type: "USER" }) user: Snowflake,
    interaction: CommandInteraction
  ) {
    await interaction.deferReply();

    const helloBtn = new MessageButton()
      .setLabel("Hello")
      .setEmoji("👋")
      .setStyle("PRIMARY")
      .setCustomId("hello-btn");

    const row = new MessageActionRow().addComponents(helloBtn);

    interaction.editReply({
      content: `${user}, Say hello to bot`,
      components: [row],
    });
  }

  @ButtonComponent()
  mybtn(interaction: ButtonInteraction) {
    console.log('processing')
    if (interaction.customId === 'hello-btn') {
      interaction.reply(`👋 ${interaction.member}`);
    }
  }
}

there console.log('processing') will be never called.

Version

Stable

Relevant log output

No response

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
Satontcommented, Oct 25, 2021

hah, i noticed thats because of - symbol in customid. Without it working like as i expect.

0reactions
VictoriqueMoecommented, Oct 25, 2021

we have a starter repo? huh, well then

https://github.com/oceanroleplay/discord.ts-example

the more you know i guess ♥

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get the id of a button that was clicked? ReactJS
Another way to grab hold of the element and its attributes is to use React refs. This is more general when trying to...
Read more >
Building a button component - web.dev
In this post I want to share my thoughts on how to build a color-adaptive, responsive, and accessible <button> element.
Read more >
The Button element - HTML: HyperText Markup Language
The HTML element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology.
Read more >
Buttons - Bootstrap
Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
Read more >
React Button component - Material UI - MUI
Buttons allow users to take actions, and make choices, with a single tap. ... and Icon Buttons are built on top of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found