Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda