My bot can't show 2 modals
I was trying to make a
bug
command 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
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 commandsi try that but they didn't work, so the only thing that can replace slash commands are buttons
ok, it worked, but still dying, (I use the Suggestion command, not the bug report command)
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"
but it exist
this is the code now (with that error fixed, but still not working without turning off one those 2 commands)
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
but in this case i need those listeners (i think?)
im not sure actually
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
mmm, let my try if i can filter by if interaction is a modal
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;
oooh, i think i understand
like this? (sorry if im wrong, im not good at v13 now)
uhhh not exactly, you should use your interaction object
and also make sure you are setting that customId in the modal
I was wrong
oh