How do I disable awaitModalSubmit?

I have a question: how can I make it so that if the filter is valid, the awaitModalSubmit gets deactivated? By default, to avoid repetition issues I use a custom ID, but is it possible to directly deactivate awaitModalSubmit
10 Replies
d.js toolkit
d.js toolkit3mo ago
Hecone
HeconeOP3mo ago
let submit: ModalSubmitInteraction | null = null;

try {
await data.showModal(modal);

submit = await data.awaitModalSubmit({
filter: (i) => i.customId == modal.data.custom_id && i.user.id === data.user.id,
time: 3_600_000,
});

//...
}
let submit: ModalSubmitInteraction | null = null;

try {
await data.showModal(modal);

submit = await data.awaitModalSubmit({
filter: (i) => i.customId == modal.data.custom_id && i.user.id === data.user.id,
time: 3_600_000,
});

//...
}
Amgelo
Amgelo3mo ago
but it gets "deactivated" if the filter passes it only collects 1
Hecone
HeconeOP3mo ago
Unfortunately, my function repeats itself several times after a few awaitModalSubmit since I defined a custom customId, it no longer happens, so I assume it repeats because of awaitModalSubmit.
Amgelo
Amgelo3mo ago
then your question doesn't match your issue
how can I make it so that if the filter is valid, the awaitModalSubmit gets deactivated
this is how it works already
since I defined a custom customId, it no longer happens
because each has a different customId, it's not passing the filter of the others
Hecone
HeconeOP3mo ago
the problem is that the fact that awaitModalSubmit is deactivated after a valid filter does not work
Amgelo
Amgelo3mo ago
that doesn't match what you described "since I defined a custom customId, it no longer happens" if your customIds aren't unique, they'll all pass, so they'll all execute if they are unique only one will pass, the rest will still be lingering but they won't execute
Hecone
HeconeOP3mo ago
so that's the only solution?
Amgelo
Amgelo3mo ago
if you want to distinguish different modals pretty much, because you don't get any notification if the user closes the modal you could also listen to interactionCreate directly instead of using collectors
Hecone
HeconeOP3mo ago
I see, thank you for the tip. I will look into the issue of awaitModalSubmit executing multiple times

Did you find this page helpful?