Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
Discord.js v13 the reaction role buttons not work after i restart the bot

This is reaction roles button command it working but after i restart the bot it say This interaction failed how can i fix it? is it impossible? i was use simplydjs it working but i can't change the message,when user got thier roles the bot will send message and i want change it but i can't so i use collect and it not working after i restart the bot so that why i ask this question.

const Command = require("../Structures/Command.js");
const Discord = require('discord.js');
const { MessageButton } = require('discord.js');

module.exports = new Command({

    name: "reactionrolebuttons",
    description: "reaction role but button",
    async run(message, args, client, interaction, collect) {
        let embed = new Discord.MessageEmbed()
            .setTitle("Ping Roles:")
            .setColor("#0099ff")
            .setDescription("`Click some button bellow if you want get notified!`")

        const row = new Discord.MessageActionRow()
            .addComponents(
                new MessageButton()
                    .setCustomId('Acm')
                    .setLabel('Announcement')
                    .setStyle('SECONDARY')
                    .setEmoji("📰"),
                new MessageButton()
                    .setCustomId('Gv')
                    .setLabel('Giveaways')
                    .setStyle('SECONDARY')
                    .setEmoji("🎉")
            )
        const m = await message.channel.send({ embeds: [embed], components: [row] });

        const iFilter = i => i.user.id === message.author.id;

        const collector = m.createMessageComponentCollector({ filter: iFilter, time: 60000 })

        collector.on('collect', async i => {
            if (i.customId === 'Acm') {
                const role = message.guild.roles.cache.get("901353036759310386");
                if (i.member.roles.cache?.has('901353036759310386')) {
                    i.member.roles.remove('901353036759310386')
                    i.reply({ content: `${role} was removed from you`, ephemeral: true });
                } else {
                    i.member.roles.add('901353036759310386')
                    i.reply({ content: `${role} was added to you`, ephemeral: true });
                }
            } else if (i.customId === 'Gv') {
                const role = message.guild.roles.cache.get("901370872827346975");
                if (i.member.roles.cache?.has('901370872827346975')) {
                    i.member.roles.remove('901370872827346975')
                    i.reply({ content: `${role} was removed from you`, ephemeral: true });
                } else {
                    i.member.roles.add('901370872827346975')
                    i.reply({ content: `${role} was added to you`, ephemeral: true });
                }
            }
        })
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

on your filter dont forget to add await i.deferUpdate()

Also your collector doesnt seem a bit using await anymore, if u wanna use async just add await too.

At collector

await i.reply("......")

on your filter

const filter = async i => {
  await i.deferUpdate()
  return i.customId && i.user.id === message.author.id;
}

[Edit] Also you need to end the collector after user clicked the button

await i.reply..........
await collector.stop("complete")

If you wanna continue to use that button for next interaction you dont need collector btw,

Just wrap the the condition on the interactionCreate event

client.on("interactionCreate", async (interaction) => {
 if (!interaction.isButton()) return;
  if(interaction.customId === "Acm") {
   \\Your code here
 }
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda