Need help with buttons
how to send a message with a set of buttons (set 1) and upon clicking a button, the message gets edited with a new set of buttons (set 2), and make set 2 functional? I have tried stuff like creating new collector, trying to collect the customId of set 2 in the same collector for set 1 but nothing works. My code currently is like https://sourceb.in/RBjdTmvmJB
28 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 OPthere's many ways to achieve this, including using a second collector
putting aside the fact that the section with the second collector is currently commented out, it seems as though you're accessing the nonexistent
matchResponse
, and you may also run into some scoping issues regarding confirmation
in your catch block
please put together something you believe would work, then we can work through why it doesn'tmatchResponse
was initially defined as sending a new message upon clicking start button and it was supposed to be editing the new message upon choosing a move, since it didn't work I commented it out and tried editing the initial message using same collector for all buttonswell
awaitMessageComponent
, the promisified component interaction collector, only collects one component interaction and resolves when it's done so
if you wanted to handle everything with one collector, you'd need to use the standard event-based collector createMessageComponentCollector
hmm, I think I'll go with 2nd collector itself
just as a note,
<Interaction>.reply()
resolves in an InteractionResponse
if you don't specify fetchReply: true
, and collectors created from InteractionResponse
s currently have a couple issues
I believe this case may not run into them, but for most cases it's recommended to specify fetchReply: true
so that it resolves in the Message
sent insteadseems more neat
hm
I've made modifications to the code: https://sourceb.in/XyWzf8GU9h
using 2nd collector
right now the issue is, it edits the initial message and sends a new message with embeds and attack component but
it only accepts the first click
any click after that leads to interaction failed message
there's no error in console
the first click as in the
start
/cancel
buttons?
or the first click of each of punch
/kick
/surrender
?this one
that's because as mentioned,
awaitMessageComponent
only collects one component interaction
if you want to use a collector to handle more than one, you'd need to use the standard event-based collector createMessageComponentCollector
ohhh
is there any guides for that?
Popular Topics: Collectors - Interaction collectors
read more Message#createMessageComponentCollector()
Creates a message component interaction collector.
alright
(it's roughly the same options as
awaitMessageComponent
)so you are suggesting I should use
createMessageComponentCollector
for punch/kick/surrender row right?sure
okay thanks! I'ma try it
btw
if I give time parameter as 30_000
will it collect only for 30s or it will start the timer after every click
the
time
option is just a standard time limit
if you want it to reset each time the collector collects something, you should use the idle
optionohh
oke
putting aside how awkwardly
message
appears to be defined, <TextChannel>.send()
is asynchronous
you were previously awaiting it
<Interaction>.followUp()
also exists and sends a follow up message through the interaction webhook if you'd prefer to go through the interactionI didn't know that
how should I define it I have no idea
why dont create message component collectar using interaction
not message
well I did something and its working now
https://sourceb.in/Ue7AZT3d07
oh there's 2 collect events
lemme remove one
nice
well I have a javascript doubt but dont feel its worth making a post
so I'll ask here
how do I import functions and use from other files?
thats basic js, #rules 3 #resources