modal followUp

https://sourceb.in/FIp4Pynb89 the 1st image is when the else statement is ran and it follows up the modal and the reply is sent successfully, and the 2nd image is when the if statement is ran but the follow up to the modal isn't sent properly, and shows that error (image 3) i'm not doing anything to the modal in the if statement, just following up like in the if statement, why isn't it replying?
10 Replies
Unknown User
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Shaurya
Shaurya•17mo ago
is modal.followUp means showing the modal?? 🤔 i'm showing the modal in both cases and then followUp to the modal
Syjalo
Syjalo•17mo ago
You have just received modal submit interaction and didn't response with initial reply. You should response with initial reply before followUp.
Shaurya
Shaurya•17mo ago
Should i do modal.reply then? When i do modal.reply, it shows the error in image 1 And when i do modal.followUp, it shows the error in image 2
chewie 🌈
chewie 🌈•17mo ago
Are you deferring the reply after receiving the modal? .reply() is only possible without deferring and only once. .followUp() is only possible after deferring or sending the first reply. No you might be doing that, but you most likely didn't resolve the promise from each call properly, so one might run before the other call, even tho the order is correct.
Shaurya
Shaurya•17mo ago
yes, this is all the things i'm doing: https://sourceb.in/cgJYTvzf9i, the save button is clicked, i create the modal, set the inputs of it and then show the modal, then i do
//create the modal collector
const modalCollector = i.awaitModalSubmit({ time: 60000 }).catch();

//modal
const modal = await modalCollector;

//get the embed name
const embedName = modal.fields.getTextInputValue("embedName");

//defer the modal
modal.deferReply({ ephemeral: true });
//create the modal collector
const modalCollector = i.awaitModalSubmit({ time: 60000 }).catch();

//modal
const modal = await modalCollector;

//get the embed name
const embedName = modal.fields.getTextInputValue("embedName");

//defer the modal
modal.deferReply({ ephemeral: true });
then if/else statement is ran, both in if/else statement, i'm doing modal.followUp as i deffered it just above, it works proper in else statement, but when if statement is ran, it doesn't followUp properly, image 2 else statement was ran, image 3 if statement was ran
chewie 🌈
chewie 🌈•17mo ago
like I said, you are not waiting for the promise of deferReply() to resolve Also you dont use .reply() after deferring
Shaurya
Shaurya•17mo ago
oh, should i add a wait of 1 sec?
chewie 🌈
chewie 🌈•17mo ago
no? slap await before deferReply
Shaurya
Shaurya•17mo ago
aah that i did by mistake but got the same problem works now i forgot to add await 💀 thanks for the help :D