Buttons instantly disappear after using slash command
https://pastebin.com/36riQB8n
The code above is my command.
The Buttons on the ephemenal message disappear instantly after calling the command.
Pastebin
SlashCommand - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
45 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!to clarify, do you also receive the
Confirmation not received within 1 minute, cancelling
message?
or are you only seeing the buttons disappear?
if you do see this message, this is likely due to you receiving ReferenceError: response is not defined
1. you should consider logging your errors
2. you seem to be using 2 collectors for the same purpose, one promisified and one not (lines 238 and 245)
3. the filter goes in the filter
option for either method, not as collector_filter
or just as the first param
4. after attempting to collect a button interaction, you seem to suddenly attempt to handle interaction
as if it's a modal submit without ever having shown a modal within this code and despite interaction
being your slash command interactionboth
I dont get any errors
i dont understand 3.
yes, that's because you're not logging the error you're catching
oh lol
here's your code:
the neither filter is actually being used
it needs to be passed to the
filter
optionI removed the frist btn collector
and changed to this:
that's still not how
awaitMessageComponent
works
it takes a single param that should be an options object
again, you need to pass the filter as the filter
option
you seemed to have already been aware of the time
option before, so I'm also not sure why you're suddenly passing what I assume is the time as the second param nowa
I'm also still not totally sure whether you've defined
response
yetuh
wait a sec
i didnt
sigh
Now I see its actually
prevMSG
instead of repsonse
after I changed to
prevMsg.resource.message.awaitMessageComponent(collector_filter, 60_000);
Still the same problemare you logging the error you're catching?
if so, have you checked what error you're receiving?
also this still applies
how can I log the System error here?
do you have an example?
if you're unsure how to log things, given some of your previous issues, I'm gonna suggest you brush up on the basics of javascript before continuing
or if you're unsure how to access the caught error from try/catch, I'd at least suggest looking at the docs for try/catch
@T A G A R O S your own code from before correctly sets the
time
option
awaitMessageComponent
takes a similar options objectok ty
oh
i see
ty
my code stop at
if (!interaction.isModalSubmit()) return console.log("Not a modal submit");
and I get not a modal
Pastebin
SlashCommand - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
new code
still same problem above
number 4 up here
createMessageComponentCollector
collects a message component interaction
which is to say, it will collect when a user clicks on a button
you then proceed to check if the slash command interaction is a modal submit (which it's not), and attempt to parse modal fields from the slash command
then afterwards you show a modal in response to the slash command which has already been responded toI changed it to
i
i changed to this now:
The problem is that the program stops at
terminal output is Not a modal submit
yes, that's because the slash command still isn't a modal submit
you still haven't shown the modal at this point, and the modal submit will be its own interaction
I also don't see this change in your filter
hm so I should show the modal when? on messageCreate?
btn_collector.on("collect", async (i) => {
thisyou may want to reread qjuh's message
yes I changed it completely and added the
btn_collector.on()
with async (i)
please pay attention to the word filter
OH
first interaction or second to change?
please reread qjuh's message in which he mentions specifically which part of your filter is the issue
ty
anyways returning to this, modals can't be shown in response to messages, only interactions
so with that in mind, when do you want the modal to be shown?
in response to the user clicking the button?
this should work then
sure
user click the button
then given that your button collector will collect your button interactions, consider showing the modal in response to the button interaction
I did
after the modals
you mean like do it before try catch?
so thinking on the parameters you recently renamed, which interaction would you say is your button interaction?
and furthermore, should the modal be shown after you handle the response to the modal?
ofc not.
I thought i was building the response first then send modal
the left one
sorry Im answering slow bc Im helpin my mom makinf dinner rn
Now after I put
await interaction.showModal(embed_Modal);
before the try
the message just removed all buttons
and Confirmation not received within 1 minute, cancelling
was showing
and error:
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
appeared
exactly where I put the new showModalthis isn't about your filter, so there isn't a "left" or "right" interaction here
what variable contains your button interaction?
which is to say where do you handle what your collector
collect
s?the
i
?Yes
As I mentioned in my first message
interaction
is your slash command interactionI changed now to
Unknown User•5d ago
Message Not Public
Sign In & Join Server To View
the filter should be that only the current user can interact with the button.... but wait
oops sorry if i pinged didnt mean to
The message is ephenemal anyways
i dont need the filter
I still get the error:
for the
await interaction.showModal(embed_Modal);
when I put the line before the try
this is the shorten version
my btn_collector
:
tag suggestion for @T A G A R O S:
If you are waiting for button or select menu input from a specific message, don't create the collector on the channel.
- Channel collectors return component interactions for any component within that channel.
ohh
the replied message
I changed to this
but I still get the same error as before at
await interaction.showModal(embed_Modal);
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
Unknown User•4d ago
Message Not Public
Sign In & Join Server To View
ohhh
thanks!
Ì already tried but got invalid form error instead
but I only have 4 rows
and 3 inputs each
oh
thats why
and how much row?
is max?
ok ty