You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a V13 modal is shown in response to a button interaction, and the user clicks Cancel the first time, then clicks the original button again, bringing up the modal again, then submits successfully, two modal submit interactions are caught by the awaitModalInteraction collector.
In this code:
try {
await request.buttonInteraction.showModal(modal);
} catch(e) {
Log.error(e.message);
throw new RuntimeError(e);
}
console.log("After showModal");
const submittedInteraction = await request.buttonInteraction.awaitModalSubmit({
time: 60000,
filter: i => i.user.id === request.userDiscordId,
}).catch(e => {
Log.error(e.message);
// TODO Catch timeout error here
throw new RuntimeError(e);
});
request.address = submittedInteraction.components[0].components[0].value;
await walletRegister(request, submittedInteraction);
walletRegister gets called twice in the cancel-then-submit scenario. ('request' is just an object used to pass context around).
Code sample
try{awaitrequest.buttonInteraction.showModal(modal);}catch(e){Log.error(e.message);thrownewRuntimeError(e);}console.log("After showModal");constsubmittedInteraction=awaitrequest.buttonInteraction.awaitModalSubmit({time: 60000,filter: i=>i.user.id===request.userDiscordId,}).catch(e=>{Log.error(e.message);// TODO Catch timeout error herethrownewRuntimeError(e);});request.address=submittedInteraction.components[0].components[0].value;awaitwalletRegister(request,submittedInteraction);
There is only one actual modal submission, i.e. the Submit button was only pressed once. The first time the modal came up the 'Cancel' button was pressed. There should only be one interaction caught by the collector since the Submit button was only pressed once.
I'm afraid repeating the issue won't get you anywhere. This is not a bug with discord.js.
There is only one actual modal submission
A user may have submitted one, but there are two modal submissions in your code in the provided scenario. You wait for a modal submission and expire the collector after 1 minute. Again, you provide no unique trait to your filter other than the user of the interaction being the same.
See #7431 (comment) for a code sample of what you want to do.
If you need further help, you can open a discussion or ask in the Discord server.
OK, so both running collectors grab submissions off the single Submit button press. I filtered on a UUID and that seemed to solve it. Thanks for your help.
Which package is this bug report for?
discord.js
Issue description
When a V13 modal is shown in response to a button interaction, and the user clicks Cancel the first time, then clicks the original button again, bringing up the modal again, then submits successfully, two modal submit interactions are caught by the awaitModalInteraction collector.
In this code:
walletRegister gets called twice in the cancel-then-submit scenario. ('request' is just an object used to pass context around).
Code sample
Package version
13.7
Node.js version
16.13.1
Operating system
Ubuntu 20.04
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
Channel, Message, Reaction
Which gateway intents are you subscribing to?
Guilds, GuildEmojisAndStickers, GuildWebhooks, GuildPresences, GuildMessages, GuildMessageReactions, DirectMessages, DirectMessageReactions
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: