Closed snxraven closed 2 years ago
¡Thanks to report the issue!
Actually, that error is not of Discord-Modals, but the error (Discord API Error) says that the interaction has already been acknowledged. That means, that interaction has already been deferred. I think you put interaction.deferReply()
right? If not, please tell me.
I did have that, however, if I remove this it still is an issue, I am looking at my code further to see if its my issue instead of bugging you and if I cannot find anything I will provide as much info as possible.
Oh ok, I'll wait for it.
If this is helpful to you, this is the commands code: (HasteBin Link) https://r-bin.ssh.surf/amovutahal.js
I am also using https://github.com/AnIdiotsGuide/guidebot and their slash command handler
I will continue to look into it aswell
Uh, I don't find the error. I recommend you to put your modalSubmit event in an Event Handler or on index.js. That can work.
@Mateo-tem Ohhhh I see, Thank you. You do bring a very valid point, I will continue to code this out and see how it goes.
No problem :)
Ok, so more trying here, I am seeing odd behavior.
Currently, I am trying this with the ping command, the command itself has no code in it:
exports.run = async (client, interaction) => { // eslint-disable-line no-unused-vars
// await interaction.deferReply();
// const reply = await interaction.editReply("Ping?");
// await interaction.editReply(`Pong! Latency is ${reply.createdTimestamp - interaction.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms.`);
}
exports.commandData = {
name: "ping",
description: "Pongs when pinged.",
options: [],
defaultPermission: true,
};
// Set guildOnly to true if you want it to be available on guilds only.
// Otherwise false is global.
exports.conf = {
permLevel: "User",
guildOnly: false
};
This is the interactionCreate.js as I have implemented your example:
https://r-bin.ssh.surf/korojumedu.typescript
Here is the bot log attempting to run the example:
https://r-bin.ssh.surf/ibidawufej.yaml
You can see in the first run everything runs smooth and I do get the proper reply in discord.
However, the second run of the command, modalSubmit is being called multiple times.
You can see the command handler is not calling the command more than the single time when the command is being ran.
As you can see here both replies are sent to discord, but the errors and the odd loop is concerning:
It is very odd and I am not too sure I understand this behavior
If you are able to spot what I may be doing wrong it would be amazing xD
Oh, I have not been able to discover the error. I don't know where to put it, but a return would be nice.
To allow while trying to figure this out ive done:
count = count + 1
if (count != 1) return
if (count == 1) {
within modalSubmit this still runs a ton of times but only really sends to the API once, its a gross bandaid to whatever issue there is
Oh ok.
Sadly, I worked for a while and was unable to find any other way to resolve the issue besides using the above count to only allow a single request from ModalSubmit.
Not too sure what the issue is adding a return anywhere in the code wont work because the module is calling ModalSubmit so many times.
I may look into this further as some point
Uh, you can put your modalSubmit event on index.js? That can work, or I don't know.
Hello There :)
First of all, I love this work, great job!
I have the modal working and I am able to use the information submitted from the form and process it perfectly.
However, this does only work error log free on the first run, on any other runs, I see this, the interesting thing is, the functionality still works, the form still pops up the information is still sent to my api as coded but this error is reported in my bots log: