#inter

55 messages · Page 1 of 1 (latest)

ruby escarp
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

copper charm
#

i use v13.8.0

delicate portal
#

you’re using a collector?

copper charm
copper charm
delicate portal
delicate portal
#

if I dont reply I'm not available

copper charm
#
client.on('messageCreate', message => {
  if (message.content === "test" || message.content === "-test") {
    const embed = new Discord.MessageEmbed()
      .setDescription("**To See Test choose**");
    let row = new MessageActionRow()
    .addComponents(
      new MessageSelectMenu()
          .setCustomId('select')
          .setPlaceholder('Selected')
          .addOptions([
              {
                  label: 'Test',
                  description: 'Test Done',
                  value: 'test',
                  emoji: '👍'
              }
          ])
      );
    message.reply({ embeds: [embed], components: [row] });
  }
});


client.on('interactionCreate', async interaction => {
if(!interaction.isSelectMenu()) return;
    if(interaction.isSelectMenu()) {
        if(interaction.values[0] == 'test') {
let embed = new Discord.MessageEmbed()
  .setDescription(`**Done**`)
        await interaction.update({embeds: [embed]})
        }
}});```
#

This is The Code

#

i want who do command only can use it

delicate portal
copper charm
#

can you give me example of filter?

delicate portal
#

you can use the user id as the custom id and check if custom id equals the user id

delicate portal
copper charm
elder apexBOT
#

Suggestion for @copper charm:
guide Interactions: Receiving select menu interactions - Component collectors
read more

copper charm
#

this v13?

copper charm
# delicate portal https://v13.discordjs.guide/popular-topics/collectors.html#interaction-collector...
client.on('interactionCreate', async (interaction) => {
  if (!interaction.isSelectMenu()) return;
  
  let messageId = interaction.messageId;

  if (interaction.values[0] === 'test') {
    let embed = new Discord.MessageEmbed()
      .setDescription('**Done**');
    await interaction.update({ messageId, embeds: [embed], components: [] });

  const collector = interaction.createMessageComponentCollector({ componentType: 'BUTTON', time: 15000 });

    collector.on('collect', (i) => {
      if (i.user.id === interaction.user.id) {
        i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
      } else {
        i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
      }
    });

    collector.on('end', (collected) => {
      console.log(`Collected ${collected.size} interactions.`);
    });
  }
});
#

it doesn't work

maiden forum
#

If you want the person who ran the command to be the only one to use it then you can reply using the ephermal: true option and it will only show it to that user. @copper charm

copper charm
maiden forum
#

It looks like you already did that?

copper charm
maiden forum
#

Whats the error?

copper charm
#

this

#
  const collector = interaction.createMessageComponentCollector({ componentType: 'BUTTON', time: 15000 });
maiden forum
#

Oh

copper charm
#

what can i do

maiden forum
#

Because it would be <Interaction>.channel.createMessageComponentCollector()

#

The function is held within the channel object, not the full interaction

copper charm
#
client.on('messageCreate', message => {
  if (message.content === "test" || message.content === "-test") {
    const embed = new Discord.MessageEmbed()
      .setDescription("**To See Test choose**");
    let row = new MessageActionRow()
    .addComponents(
      new MessageSelectMenu()
          .setCustomId('select')
          .setPlaceholder('Selected')
          .addOptions([
              {
                  label: 'Test',
                  description: 'Test Done',
                  value: 'test',
                  emoji: '👍'
              }
          ])
      );
    message.reply({ embeds: [embed], components: [row] });
  }
});




client.on('interactionCreate', async (interaction) => {
  if (!interaction.isSelectMenu()) return;
  
  let messageId = interaction.messageId;

  if (interaction.values[0] === 'test') {
    let embed = new Discord.MessageEmbed()
      .setDescription('**Done**');
    await interaction.update({ messageId, embeds: [embed], components: [] });

  const collector = interaction.channel.createMessageComponentCollector({ componentType: 'BUTTON' });
    collector.on('collect', (i) => {
      if (i.user.id === interaction.user.id) {
        i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
      } else {
        i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
      }
    });

    collector.on('end', (collected) => {
      console.log(`Collected ${collected.size} interactions.`);
    });
  }
});
#

this is all of code

maiden forum
#

In your code you're removing all components from the interaction before even running the collector. How are you going to detect if someone clicks a button if there is no button

copper charm
maiden forum
#

Yup

copper charm
#

how i get one in select

maiden forum
#

You want it to collect once a user selects something on a selectmenu?

maiden forum
#

On the original message right?

copper charm
maiden forum
#

Uhh you wouldn't be using a collector at all.. You would just run the check on the users ID in the interaction create event instead.

copper charm
maiden forum
#

You right click on the user and press copy ID

copper charm
#

no i mean how i would just run the check on the users ID in the interaction create event instead

maiden forum
#

By checking <Interaction>.user.id and comparing it to the user ID you want to use

copper charm
#

ok

#

thx

copper charm