listening to buttons...
this is the handler for components that i use, but i want to be able to listen to buttons also only by the first argument in the array of their customId.split('_')[0].
handler https://sourceb.in/TjIgnV1V9u
interactionCreate event https://sourceb.in/4W7NWPrkV7
button module example https://sourceb.in/DIOCZiJsIF
message send command https://sourceb.in/CiELYf68Re
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OP?
in this case, for example, i want to be able to listen to both the buttons with customId 'prova_1' and 'prova2' by listening to 'prova'
so `const component = client.collection.components.buttons.get(interaction.customId).split('')[0];`
?
?
so
?
I would first ensure that the customId has "_" if I were you
obviously infact i want to be able to listen also to buttons with normal custom ids
however, how to do that?
@Qjuh so is this correct ?
ok thanks
yeah
and it doesn’t work
TypeError: Cannot read properties of undefined (reading 'split')
no
same error
i tried both btw
ok so it works but
i want, when executing the button, to be able to get the other arguments in the button customid array
it wasnt working bc i put this in the button file ${interaction.customI.split('')[1]}
in this case it has a indeed
the customid infact is prova_1
ok fixed
thank you very much