My collector isn't triggering, but is being created. There are no errors in console.
Hello everyone. I have a slash command script that allows people to host giveaways in a local boardgame club I am a part of.
In my script I have two button interaction collectors. The first one to trigger is to confirm that the person has read the rules that show up on an embed. This collector works great. The second collector that triggers is for when someone inputs a date that does not follow the regex in the script to error check before sending the message. This collector gets created properly (I think) but does not see any button presses, and I am not sure why.
The collector I am having issues with is created on line 28.
My script:
https://pastebin.com/J84GRdH8
There are no errors, no stack traces, and no promise rejections. I am running 14.17.3 D.js and node 20.11.1.
Pastebin
giveaway.js - 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.
10 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!Pass
fetchReply: true
to your reply options
Alternatively, the better option is using withResponse: true
if you have latest d.js which will return InteractionCallbackResponse
, which returns the created message, so you can do
<response>.resources.message.createMessageComponentCollector()
Also await is useless there:class: InteractionCallbackResponse
[email protected]
Represents an interaction's response
:property: InteractionCallbackResponse#resource [email protected]
The resource that was created by the interaction responseSo I got it to work with fetchReply: true, but I am confused by the better options.
Heres what lines 25 and 28 look like now:
I am not sure why this is better, either. Is it just because fetchReply is deprecated?
Yes, it'll be removed in v15, that should work
I am getting the error:
TypeError: Cannot read properties of undefined (reading 'message')
The error is on line 28, or line 3 in that code blockCan you log
retryMessage
?Yeah will do
It returns a promise XD
I am gonna put await back in and see what happens
Oh right, yeah you need to resolve the promise, the
await
i was talking about is for creating the collector, it's not asyncOh right, good point.
I am having trouble copying the error for whatever reason. Let me try doing it from bash instead of portainer
It's because it's
resource
not resources
Also, it's createMessageComponentCollector()
not createMessageCollector()
.
It's working now! Thank you for your help!
I will remove the extra await XD