My bot can't show 2 modals

I was trying to make a bugcommand and bot suggestion command with a button that shows a modal and then send the content to a specific channel in my bot support server, but only works if one of those 2 commands are disabled; when I test those 2 commands without turning off one of these, they mix and bot dies. what can I do :(
15 Replies
monbrey
monbrey3y ago
The problem is here: const bugReportado = interaction.fields.getTextInputValue('bugModal'); Basically the modal it collected doesnt have that field Because your modal collecting is wrong It would be far easier if you were using slash commands
TRKako
TRKakoOP3y ago
i try that but they didn't work, so the only thing that can replace slash commands are buttons
TRKako
TRKakoOP3y ago
ok, it worked, but still dying, (I use the Suggestion command, not the bug report command)
ShompiFlen
ShompiFlen3y ago
same as before, you are trying to get a field of the modal that doesn't exist. Your last modal is missing a field with this custom id "buginputModal"
TRKako
TRKakoOP3y ago
but it exist
TRKako
TRKakoOP3y ago
this is the code now (with that error fixed, but still not working without turning off one those 2 commands)
ShompiFlen
ShompiFlen3y ago
make sure you are trying to get it out from the correct modal object then I think your error is mostly because you have two listeners for the same thing, you should always just have one listener for interactions and one for messages Also you could filter by the modal's custom id and not just if the interaction is a modal or not
TRKako
TRKakoOP3y ago
but in this case i need those listeners (i think?) im not sure actually
ShompiFlen
ShompiFlen3y ago
im pretty sure you are getting that error because both listeners are receiving the same modal independent if one is a bug modal or a suggestion modal, so in one of them theres gonna be a missing field error. Either filter out the modals by the custom id and hopefully merge both interactionCreate listeners into one
TRKako
TRKakoOP3y ago
mmm, let my try if i can filter by if interaction is a modal
ShompiFlen
ShompiFlen3y ago
no you need to filter out by the modal's custom id, if it has one, that would help you out a bit, for example if(modalInteraction.customId !== "bugreport") return;
TRKako
TRKakoOP3y ago
oooh, i think i understand
TRKako
TRKakoOP3y ago
like this? (sorry if im wrong, im not good at v13 now)
ShompiFlen
ShompiFlen3y ago
uhhh not exactly, you should use your interaction object and also make sure you are setting that customId in the modal
TRKako
TRKakoOP3y ago
I was wrong
C:\Users\Kako\Desktop\Discord Bot Dev Files\Bots Code\TRKbot\TRKbot v13\index.js:471
if(modalInteraction.customId !== "bugreport") return;
^

ReferenceError: modalInteraction is not defined
C:\Users\Kako\Desktop\Discord Bot Dev Files\Bots Code\TRKbot\TRKbot v13\index.js:471
if(modalInteraction.customId !== "bugreport") return;
^

ReferenceError: modalInteraction is not defined
oh
Want results from more Discord servers?
Add your server