discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.23k stars 3.96k forks source link

can't create message collector on ephemeral response without fetching. #7992

Open imranbarbhuiya opened 2 years ago

imranbarbhuiya commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

InteractionCollector isn't collecting interaction when used along with an ephemeral button interaction reply without fetching. If I fetch the reply or remove ephemeral then it works fine.

Code sample

client.on('interactionCreate', async (interaction) => {
    if (!interaction.isButton()) {
      return;
    }

    const msg = await interaction.reply({
      content: 'test',
      components: [
        new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents([
          new ButtonBuilder()
            .setCustomId('test')
            .setLabel('test')
            .setStyle(ButtonStyle.Primary),
        ]),
      ],
      ephemeral: true,
    });

    msg
      .createMessageComponentCollector({
        componentType: ComponentType.Button,
      })
      .on('collect', (btn) => {
        console.log(btn.customId);
      });
  });
}

Package version

v14

Node.js version

v16.15.0

Operating system

Windows

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

Not applicable (subpackage bug)

Which gateway intents are you subscribing to?

Not applicable (subpackage bug)

I have tested this issue on a development release

68d5169

suneettipirneni commented 2 years ago

I cannot reproduce. Sample code:

client.on('interactionCreate', async (interaction) => {
    if (!interaction.isChatInputCommand()) {
      return;
    }

    const msg = await interaction.reply({
      content: 'test',
      components: [
        new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents([
          new ButtonBuilder()
            .setCustomId('test')
            .setLabel('test')
            .setStyle(ButtonStyle.Primary),
        ]),
      ],
      ephemeral: true,
    });

    msg
      .createMessageComponentCollector({
        componentType: ComponentType.Button,
      })
      .on('collect', (btn) => {
        console.log(btn.customId);
      });
  });
}
kyranet commented 2 years ago

@imranbarbhuiya are you still able to reproduce this? Does the sample above work for you?

suneettipirneni commented 2 years ago

We talked on discord I'm able to reproduce it now. The issue is with replying with message components, still looking through to see if this is possible to fix.

migue802 commented 1 year ago

Is this going to be fixed? I have the same issue - can repro

Edit: using autoFetch fixed it, still annoying

didinele commented 2 months ago

Relevant internals https://canary.discord.com/channels/222078108977594368/999796393810067607/1259087857130278962