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

240
Views
interaction collector discord.js collects all interactions that are executed after the collector declaration

Meaning: there is some content and a button in the response to the slash command. The task of the button is to delete the message. What we managed to do was to force the button to delete the message, but the problem is that not only the message in which the button is deleted, but also other messages.

const {
  MessageEmbed,
  MessageActionRow,
  MessageButton
} = require('discord.js')
const {
  SlashCommandBuilder
} = require('@discordjs/builders')
const Color = 'RANDOM'
module.exports = {
    name: 'Name',
    data: new SlashCommandBuilder()
      .setName('Name')
      .setDescription('Description')
      .addStringOption(option => option.setName('choice')
        .setDescription('Description')
        .setRequired(true)
        .addChoice('choice1', 'choice1')
        .addChoice('choice2', 'choice2')
        .addChoice('choice3', 'choice3') 
    async run(interaction) {
          const Embed = new MessageEmbed()
            .setColor(Color)
            .setTimestamp()
            .setImage(url)
          const Btns = new MessageActionRow()
            .addComponents(new MessageButton()
              .setCustomId('DeleteMsg')
              .setStyle('DANGER')
              .setLabel('Удалить сообщение (Только автор или администратор)'))
          interaction.reply({
            embeds: [Embed],
            components: [Btns]
          })
          try {
            const collector = interaction.channel.createMessageComponentCollector({
              time: 60000
            })
            collector.on('collect', async i => {
              interaction.deleteReply()
            })
          } catch (error) {
            console.log(error)
          }
   }
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ok first of all, you should always add a filter to your component collector. (How many items to collect, check if correct users used your component, ...)

You should also have a real custom ID (like an UUID or something like that) because if there's multiple calls of your command in the same channel then, your custom ID wouldn't be custom anymore and could be collected by every collector running in the channel.

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!