#Unknown Interaction button

22 messages · Page 1 of 1 (latest)

thick wharf
#

this randomly happens

const embed = new EmbedBuilder()
                .setColor("#ffaa00")
                .setTitle("📋 Account Application")
                .addFields(
                    { name: "Username", value: username },
                    { name: "Write a background story of your character", value: q1 },
                    { name: "Explain \"Powergaming\" & \"Metagaming\"", value: q2 }
                )
                .setTimestamp();

            await interaction.message.edit({
                content: `✅ Application **${status}** by <@${interaction.user.id}>`,
                embeds: [embed],
                components: []
            });
hot barnBOT
thick wharf
next sableBOT
#

Common causes of DiscordAPIError[10062]: Unknown interaction:

  • Initial response took more than 3 seconds ➞ defer the response *.
  • Wrong interaction object inside a collector.
  • Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
    * Note: you cannot defer modal or autocomplete value responses
covert bison
#

The first one seems like the most likely... that you're just taking too long to respond to the interaction

Additionally, you shouldn't be doing interaction.message.edit as interactions have their own dedicated endpoints for messages... if you want to modify the message the buttons are attached to, you should use interaction.update

next sableBOT
#

method ButtonInteraction#update() [email protected]
Updates the original message of the component on which the interaction was received on.


// Remove the components from the message
interaction.update({
  content: "A component interaction was received",
  components: []
})
  .then(console.log)
  .catch(console.error);

thick wharf
#

but most likely its from the 3 seconds thingies

#

ill reach out again

covert bison
#

if you're interacting with a database prior to the update... then you should use deferUpdate then editReply

thick wharf
#

it is not from the 3 seconds thing

#

i tried waiting for like 15 seconds before clicking the button and it still works

#

it randomly happens idk why

covert bison
#

the 3 seconds isn't a clientside issue... it's an api issue. from the moment the button is clicked, your bot has 3 seconds to respond... if youre interacting with a database (or any other external entity), then there's an unpredicable amount of time that can pass for the data to be returned... so you can "miss interactions" if those services take longer than expected

thick wharf
#

ohh i get it

covert bison
#

the solution of instantly deferring the update is there so your bot tells discord "hey, i got your interaction... i'll deal with it later though, please don't fail the interaction"

thick wharf
#

i put it right after the pressing button event right?

covert bison
#

put it as soon as possible in your code... from the moment you received the interaction

client.on("interactionCreate", interaction => {
    if (!interaction.isButton()) return
    
    await interaction.deferUpdate()
    
    // Rest of the code here...
}
thick wharf
#

already did what u said but in rare rcase its still happening

covert bison
#

Then it's less likely a code issue and more likely a network/hardware issue

thick wharf
#

i guess so

#

cuz there was like 50 applications submmited at once lol