#Cannot Update `interaction` After Replying

5 messages · Page 1 of 1 (latest)

half fern
#

• 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.

teal jacinth
#

alrighty

#

my fault

#
const config = require("./config.json")

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const { REST, Routes, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const rest = new REST({ version: '10' }).setToken(config.TOKEN);

const wait = require('node:timers/promises').setTimeout;

const commands = [
  {
    name: "ping",
    description: "Replies with Pong!",
  },
  {
    name: "duel",
    description: "Let's duel!",
    options: [{
        name: "challenging",
        description: "Who will you challenge..?",
        type: 6
    }] 
  }
];

(async () => {
  try {
    console.log('Started refreshing application (/) commands.');

    await rest.put(Routes.applicationCommands(config.CLIENT_ID), { body: commands });

    console.log('Successfully reloaded application (/) commands.');
  } catch (error) {
    console.error(error);
  }
})();


client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

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

    switch (interaction.commandName) {
        case 'duel':
            await interaction.reply(
                {
                    content:`${interaction.user} has challenged you to a duel! Do you accept ${interaction.options.get('challenging').user}?`, 
                    components: [
                        new ActionRowBuilder().setComponents(
                            new ButtonBuilder()
                                .setCustomId('accept')
                                .setLabel('Accept')
                                .setStyle(ButtonStyle.Success),
                            new ButtonBuilder()
                                .setCustomId('decline')
                                .setLabel('Decline')
                                .setStyle(ButtonStyle.Danger)
                        )       
                    ]
                }
            )
    } 
});



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

    switch (interaction.customId) {
        case 'accept':
            await interaction.reply("You have accepted the duel!")
        case 'declined':
            await interaction.reply("You have declined the duel...")
    }

    await interaction.deferUpdate({components: []})
})

client.login(config.TOKEN);```
#
Uncaught DiscordjsError Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
    at DiscordjsError (undefined:18:32)
    at reply (undefined:102:46)
    at <anonymous> (undefined:78:31)
    at processTicksAndRejections (undefined:96:5)
    --- TickObject ---
    at init (undefined:25:19)
    at emitInitNative (undefined:202:43)
    at emitInitScript (undefined:505:3)
    at nextTick (undefined:133:5)
    at <anonymous> (undefined:372:17)
    at processTicksAndRejections (undefined:96:5)
    --- Promise.then ---
    at addCatch (undefined:369:12)
    at emit (undefined:533:9)
    at handle (undefined:81:12)
    at module.exports (undefined:4:36)
    at handlePacket (undefined:352:31)
    at onPacket (undefined:480:22)
    at onMessage (undefined:320:10)
    at onMessage (undefined:199:18)
    at emit (undefined:513:28)
    at receiverOnMessage (undefined:1178:20)
    at emit (undefined:513:28)
    at dataMessage (undefined:528:14)
    at getData (undefined:446:17)
    at startLoop (undefined:148:22)
    at _write (undefined:83:10)
    at writeOrBuffer (undefined:391:12)
    at _write (undefined:332:10)
    at Writable.write (undefined:336:10)
    at socketOnData (undefined:1272:35)
    at emit (undefined:513:28)
    at addChunk (undefined:315:12)
    at readableAddChunk (undefined:289:9)
    at Readable.push (undefined:228:10)
    at onStreamRead (undefined:190:23)
    at callbackTrampoline (undefined:130:17)
    --- TLSWRAP ---
    at init (undefined:25:19)
    at emitInitNative (undefined:202:43)
    at TLSSocket._wrapHandle (undefined:620:24)
    at TLSSocket (undefined:519:18)
    at connect (undefined:1628:19)
    at tlsConnect (undefined:1032:14)
    at ClientRequest (undefined:341:45)
    at request (undefined:357:10)
    at initAsClient (undefined:841:28)
    at WebSocket (undefined:85:7)
    at exports.create (undefined:35:14)
    at <anonymous> (undefined:275:47)
    at connect (undefined:202:12)
    at createShards (undefined:247:19)
    at connect (undefined:167:17)
    at processTicksAndRejections (undefined:96:5)
    --- async function ---
    at login (undefined:232:21)
    at <anonymous> (undefined:84:8)
    at Module._compile (undefined:1126:14)
    at Module._extensions..js (undefined:1180:10)
    at Module.load (undefined:1004:32)
    at Module._load (undefined:839:12)
    at executeUserEntryPoint (undefined:81:12)
    at <anonymous> (undefined:17:47)