Mateo-tem / discord-modals

discord-modals is a package that allows your bot of discord.js v13 to create the new Discord Modals and interact with them.
https://www.npmjs.com/package/discord-modals
MIT License
93 stars 27 forks source link

Interaction already acknowloedged when sending the Modal #84

Closed sirlupusdev closed 2 years ago

sirlupusdev commented 2 years ago

Good evening,

when I want to send the modal with showModal() it gives me the error SHOW_MODAL_ERROR: An error occurred when showing a modal. DiscordAPIError: Interaction has already been acknowledged.

I think, when I use showModal(), it tries to reply to an interaction, no matter if a reply has been sent before (which I do).

My basic code structure is

client.on('interactionCreate', async interaction => {
    if (!interaction.isContextMenu()) return;
    if (!interaction.inGuild()) return;
    if (!interaction.name === 'Request Moderation Action') return;

    await interaction.reply({content: `${loadingemoji} Verifying access, hold tight...`, ephemeral: true});

    // Checking if user has the permission to open the form here (removed so it doesn't get messy

    const form = new Modal() // All the options are here, I just removed them so it doesn't get messy

    interaction.editReply({content: `${successemoji} I've sent you a form with instructions, please execute the action again if you accidentally closed it out.`, ephemeral: true});

    showModal(form, {client: client, interaction: interaction});
});

Is there any workaround or plan on fixing this issue? Or is it already fixed and I'm just missing something?

Mateo-tem commented 2 years ago

The showModal() method is a response of an interaction. also reply() or deferReply() are responses of an interaction. If you give a response, you can't give a response again. So you need to remove reply() and editReply().

sirlupusdev commented 2 years ago

I’m aware of that, is there any way that would switch the showModal() method to a followUp() instead of reply()?

sirlupusdev commented 2 years ago

Or - if it's possible - as a feature Request, something like a showModalFollowUp() would be very nice (if discord API allows that of course).

sirlupusdev commented 2 years ago

Issue closed, I dug a bit into the Endpoints and it isn't possible. Thank you :)