discordjs-button-pagination icon indicating copy to clipboard operation
discordjs-button-pagination copied to clipboard

"Error [INTERACTION_ALREADY_REPLIED]" when embed reply occurs

Open jkl2k2 opened this issue 3 years ago • 10 comments

I noticed that every time I called "paginationEmbed()" I would receive an error stating that the Interaction has already been "sent or deferred". I dug around the code and found that commit 95a0108 in PR #35 seems to cause this.

Since line 36 guarantees that the interaction will be deferred, the next reply has to be an editReply() call and not reply(). Otherwise, the reply() call occurring right after guaranteeing the interaction is deferred will always error no matter what.

jkl2k2 avatar Jan 06 '22 06:01 jkl2k2

#34 this would cause the issue to reappear

ryzyx avatar Jan 07 '22 03:01 ryzyx

Are you sure the issue is related to the use of editReply()? Wouldn't discord.js give an error stating such instead of saying it's a non-existent function? I'm wondering if #34 is caused by them using the interaction version of the package on a message.

jkl2k2 avatar Jan 07 '22 04:01 jkl2k2

could be the case ngl, but 3 people are experiencing it so I'm not sure

ryzyx avatar Jan 07 '22 04:01 ryzyx

and if changing it to reply() fixed it for them, then the wrong package couldn't be the issue

ryzyx avatar Jan 07 '22 04:01 ryzyx

Hmm, did it fix the issue? I don't see any responses after #35 was merged. Either way, changing it to editReply() fixed it for me due to the aforementioned issue with replying to a deferred interaction.

From testing it, calling the interaction version of the package on a message results in the exact error mentioned in #34 (since, obviously, messages don't have an editReply() function). Calling it on an interaction without the fix results in an error saying the interaction has already been deferred or replied to. So that's why I think #34 is caused by an error on the bot dev's side and not the package.

EDIT: Also, calling editReply() on an interaction reply that hasn't been sent yet, as #35 had mentioned, will error with the message "Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred", and not the error that was reported in #34.

jkl2k2 avatar Jan 07 '22 04:01 jkl2k2

Here's some examples of the testing I did with a command I'm working on:

Using paginationEmbed with a message instead of an interaction (using the wrong package version). image

Using paginationEmbed without the change: image

Using paginationEmbed with the fix I made: image

jkl2k2 avatar Jan 07 '22 04:01 jkl2k2

Hmm okay, I'll look into it

ryzyx avatar Jan 07 '22 05:01 ryzyx

Any updates? I am having this issue as well

AshuTheDoughnut avatar Jan 07 '22 14:01 AshuTheDoughnut

Has been updated to v3.0.0, kindly install from npm

ryzyx avatar Jan 10 '22 03:01 ryzyx

// Gives the user a menu to choose from.
        interaction
          .reply({
            ephemeral: false,
            embeds: [menu],
            components: [menuRow],
            fetchReply: true,
          })
          .then(() => {
            const filter = (i) => {
              i.deferUpdate();
              return i.user.id === interaction.user.id;
            };
            interaction.channel
              .awaitMessageComponent({
                filter,
                componentType: "BUTTON",
                time: 30000,
              })
              .then((choice) => {
                if (choice.customId === "btn_Featured") {
                    paginationEmbed(interaction, featuredPages, navButtons, 30000)
                }
              })
              .catch(function (error) {
                console.log(error);
              });
          });

So, if I try to create this new paginated embed, by clicking on a button of another interaction, I get this error as well. Any way to go around this?

EDIT: I fixed my problem by deleting the if (interaction.deferred) condition in your index.js

bsdesire avatar May 10 '22 17:05 bsdesire