0

I'm trying to make a discord bot which will track your hack club arcade sessions, but I am coming across the issue

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
    at ChatInputCommandInteraction.reply (/opt/render/project/src/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:104:46)
    at /opt/render/project/src/commands/arcade/start.js:89:29
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.execute (/opt/render/project/src/commands/arcade/start.js:31:9)
    at async Object.execute (/opt/render/project/src/events/command.js:16:4) {
  code: 'InteractionAlreadyReplied'
}
await interaction.deferReply();
                    const sentMsg = await interaction.editReply("Session started!");

                    const thread = await sentMsg.startThread({
                        name: `${interaction.user.username}'s Arcade Session`,
                        autoArchiveDuration: ThreadAutoArchiveDuration.OneHour,
                        reason: `${interaction.user.username} finished their hour!`
                    });

                    const button = new ButtonBuilder()
                    .setLabel("Enable bridge")
                    .setStyle(ButtonStyle.Success)
                    .setCustomId("enableBridge")
                    const actionRow = new ActionRowBuilder()
                    actionRow.addComponents([button])

                    const reply = thread.send({ content: `<@${interaction.user.id}> started a 1 hour arcade session!`, components: [actionRow] })
                    const b = await reply.awaitMessageComponent({ time: 3_600_000 }) // 1 hour
                    const startTime = Date.now()
                    if(b.user.id == interaction.user.id){
                        if(b.customId == "enableBridge"){
                            const collectorFilter = i => i.user.id === interaction.user.id;
                            const collector = new MessageCollector(thread, {collectorFilter, time: 3_600_000 })
                            collector.on("collect", (message) => {
                                // oh no the scary part where I need to actually bridge the message
                            })

                            collector.on("end", (message) => {
                                thread.send(`<@${interaction.user.id}> finished their hour!`)
                            })
                        }
                    } else {
                        b.reply({ content: `These buttons aren't for you!`, ephemeral: true });
                    }

I have tried switching around the defer() and switching the MessageCollector around, but I could not find anything.

2
  • Can you share the full error message?
    – Quezaquo
    Commented Jul 9 at 6:55
  • @Quezaquo the message has been updated
    – DevCmb
    Commented Jul 9 at 13:26

0

Browse other questions tagged or ask your own question.