Multiple Button Handlers, only 1 takes in a request
currently, I have 2 seperate files that both have button handlers. However, when a button is pressed, it only does parsing in 1 of the files. Both are in the
interaction-handlers
directory.
src/interaction-handlers/operation.ts
src/interaction-handlers/profile.ts
16 Replies
(also the first file is the one that does work)
are you sure your custom IDs are set correctly? There is no reason why it shouldnt execute all. For example @Dragonite has many handlers and for that bot they are also all executed
Discord bots that use @sapphire/framework v4
- Official Bot Examples ᴱ ᴰ ᴶˢ
- Gemboard ᴱ ᴰ
- Dragonite ᴱ ᴰ
- Radon ᴱ ᴬ
- Sapphire Application Commands Examples ᴱ
- Archangel ᴱ ᴰ
- Zeyr ᴰ ᴬ
- Birthdayy ᴰ
- KBot ᴱ ᴬ ᴰ
Discord bots that use @sapphire/framework v3
- Arima ᴱ
- Nino ᴱ ᴰ
- Operator ᴱ ᴬ ᴰ
- Spectera ᴬ
Discord bots that use @sapphire/framework v2
- Materia ᴱ
- RTByte ᴱ ᴬ
- Skyra ᴬ ᴰ
- YliasDiscordBot ᴬ
ᴱ: Uses ESM (if not specified then uses CJS)
ᴬ: Advanced bot (if not specified it is a simple bot, or not graded)
ᴰ: Uses Docker in production
ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
oh hi there! I did some testing and apprently it was because i had a button and select menu handler in the same file because they were both related, i did seperate them and it seemed to work fine...
while i'm here though, im having troubles with a modal, im sending a modal after a chat input cmd interaction and it isnt displaying and says "interaction failed" on my client, no errors in the terminal and i have a console.log right before the showmodal, and it logs but doesn't seem to work?
https://micro.sylo.digital/i/Dhmxgs
the modal is correct and doesn't have any issues (some text being too long)
Having multiple interaction-handlers in the same file is possible if you give them distinct names. That can be set when calling
super
. (The logic for registering pieces is dependent on the name
property. If there's no name then it'll infer one from the file name.)
For the modal submission, there's nothing wrong that stands out in the command. So double check that you're parsing/handling the custom ID properly in the interaction-handler.
One thing I like to do is create custom IDs in a string Enum or function so that the format is the same every time. Makes life easier than having to remember the format between files.its the the itneraction handler for the modal
its just
it never sends the modal
💀
Whats the code in the
parse
for that handler? Try putting a console.log
for the custom ID before you return a none
If there's nothing, then the handler isnt registering properly. If the received ID is different than what you're parsing, then theres the issue.
Oh wait, you mean the modal isnt showing at all?
Since you removed the defer
for showing a modal, all of the editReply
need to be changed to reply
.
its not the handler
the modal never sends
Evidently you didn't read my messages where I realized that, also it helps to not be rude to the people helping you.
Anyways, I assume you didn't disable the command error listeners? Otherwise re-enable that. And you'll need to do that
reply
change as I said.i didnt think i was being rude, sorry
i didnt disable any command error listeners, but i will do the reply change
but yes the modal isnt showing at all
What do the question rows look like?
Thanks. It's cause you can only have 1-5 rows for modals, so 9 is too much. Not sure why you're not getting an error in logs for that. I got
data.components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 5 in length.
when running it myself.
Maybe check your logging levels? Anyways you should be all good now.hm i agree i should have gotten some notice, never knew that i could only have 5 inputs total?
i might have to split this into 2 phases
will test this out later tonight and get back
👍
Probably mark this as the answer, and open another forum submission if you still have the other issue