#handling multiple button clicks on collector
1 messages · Page 1 of 1 (latest)
i don't know if you intend to add dropdowns to this or whatnot, but it's good practice to check if the reaction is a button before doing anything else
how would i do that? im reading through djs docs right now
cant find anything in there atm though
and then inside those, you can check for the custom ids and handle each one accordingly
ohh, let me try that right now
make sure you remove that id checking from your filter first
go through this again with me, you want to handle multiple button clicks?
your handling edits out the buttons out of the message entirely, so a second button can't be pressed
do you still wish to handle multiple button clicks?
i do
does this look right?
collector.on('collect', async i => {
if(i.isButton()){
if(i.customId === 'athrust'){
await i.update({ content: 'pressed thrust', components: [] });
}
}
});```
i don't know if that's gonna work because the i interaction is a button press, so i don't think there will be a message to be updated?
oh wait, but for "filter" i had const filter = i => i.customId === 'athrust' && i.user.id === '842573885076406283';
i assume you want to edit the original message that has buttons, right?
yes, that is correct
you can update to this for now and add more stuff later if necessary:
const filter = (i) => i.user.id === interaction.user.id;
this filter assumes that only the interaction user will click the buttons. other users will get 'interaction failed' error. make sure your users understand that's normal for them to be nosy on someone else's command
the answer to your initial issue was much easier, you just had to add both options to the filter, like this
const filter = i => (i.customId === "poke" || i.customId === "pinch") && i.user.id === '842573885076406283'; then in the collector update the message accordingly
you would be checking the customId again inside the collector, that's just more code to do the same thing
yeah, i see
it would've been one if statement to separate both if (b.customId === "pinch"){}else{}
I dont see how much more code is that 
there is no need to check for the value twice, which is what your suggestion does
just a question - how can i make it so that after the 15000 milliseconds pass, it will edit the interaction and say "time's up?"
collector.on('end', i.update({content: `okay, time's up.`, components: []}));```
says that i is not defined
do you have the original message object?
are you getting the message from a slash command reply or a message create?
slash command
oh nevermind - this works
collector.on('end', async i => {interaction.editReply({content: `okay, time's up.`, components: []})});