71 Replies
d.js toolkit
d.js toolkit2d ago
- 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 staff
rockers6879
rockers6879OP2d ago
No description
duck
duck2d ago
there is no intent named Interactions, so GatewayIntentBits.Interactions is undefined
rockers6879
rockers6879OP2d ago
So remove the interaction?
treble/luna
treble/luna2d ago
yes Where did you event get that from
rockers6879
rockers6879OP2d ago
I will try that* discord.js docs
treble/luna
treble/luna2d ago
Impossible
rockers6879
rockers6879OP2d ago
went to chatgpt for debug and gave me this 😭
treble/luna
treble/luna2d ago
Yeah there is your issue
rockers6879
rockers6879OP2d ago
😭
treble/luna
treble/luna2d ago
Never ask ai Because this is the result Use the docs
rockers6879
rockers6879OP2d ago
Ahh Okay Thanks so much! One last question So i made a drop down right, and the rules wont show when I click on the drop down for the server rules No errors:
treble/luna
treble/luna2d ago
a channel select menu?
d.js docs
d.js docs2d ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
rockers6879
rockers6879OP2d ago
ah right lemme get my source bin sorry https://srcb.in/ciMHUg6ZOI
treble/luna
treble/luna2d ago
and where do you handle the select menu interaction
rockers6879
rockers6879OP2d ago
oh I need to have a handler for it?
treble/luna
treble/luna2d ago
yes Your code wont magically do something
rockers6879
rockers6879OP2d ago
hmmm, i am looking at the guide rn and dont see it. am i lost or smth...
d.js docs
d.js docs2d ago
:guide: Message Components: Component interactions read more
rockers6879
rockers6879OP2d ago
well i was looking at the wrong one... thanks ! i will try this Ok, im looking through and im not sure what to do.... Not sure which one to use for this, and where to put it
duck
duck2d ago
well that's entirely up to you the above guide mentions some of the pros/cons of each method of receiving interactions, but if you have a more specific question, feel free to ask
rockers6879
rockers6879OP2d ago
yeah, honestly im really lost with it. im not sure where to put it, where to handle it or whatever.
duck
duck2d ago
in terms of where to put code, that also depends on you you're free to listen to events anywhere you like as mentioned in the interactionCreate event section of the guide, we also have an event handling guide if you'd like to organize your events into individual files as for either type of collector, you'd probably want to utilize those immediately after sending the message with the components
rockers6879
rockers6879OP2d ago
so I should put the code inside of my events folder?
duck
duck2d ago
have you set up an event handler to handle events in an events folder?
rockers6879
rockers6879OP2d ago
i belive so let me double check yes yeah im not listening to you.... ur my friend first off
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
rockers6879
rockers6879OP2d ago
second, you know less than me 😭
duck
duck2d ago
if you two are friends and crimson is just messing with you, please take this elsewhere
rockers6879
rockers6879OP2d ago
were friends, but I need actual help... idk why he came in here
monbrey
monbrey2d ago
Well he won't be here anymore lol
rockers6879
rockers6879OP2d ago
Thanks! anyway
rockers6879
rockers6879OP2d ago
No description
rockers6879
rockers6879OP2d ago
does this workj? work*
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
rockers6879
rockers6879OP2d ago
i did but its still not sending or the dropdown is still failing
duck
duck2d ago
then you'll probably want to log throughout to ensure the following: - your event handler is properly listening to the event - the listener is correctly identifying the component (or in general the logic I assume you have behaves as expected) - the code for responding to the interaction actually executes
d.js docs
d.js docs2d ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
rockers6879
rockers6879OP2d ago
This is the code, let me send in source bin https://srcb.in/dsZdKBwoMC wait, would I need to update my index file?
duck
duck2d ago
I don't see any code for responding to component interactions please reread the interactionCreate event section in the guide
rockers6879
rockers6879OP2d ago
ok, let me reread
rockers6879
rockers6879OP2d ago
this?
No description
duck
duck2d ago
the section is a little longer than just that, but yes that is the section
rockers6879
rockers6879OP2d ago
ik the section, but i meant the code itself
rockers6879
rockers6879OP2d ago
No description
duck
duck2d ago
please actually read the guide instead of just looking at the code block
rockers6879
rockers6879OP2d ago
let me re read i read through the select menu part, and still extremely lost
duck
duck2d ago
care to share your updated code?
rockers6879
rockers6879OP2d ago
well, i havent updated anything because im not sure what to do at all.... this has stumped me for like 2 days..
duck
duck2d ago
is it possible you still haven't read past the first code block from this section?
rockers6879
rockers6879OP2d ago
i read the information it said for the select menus
duck
duck2d ago
but you've opted not to add an if statement for select menus? I'm just trying to confirm whether your code genuinely looks exactly the same as it does here or not
rockers6879
rockers6879OP2d ago
no i deleted that cause it wasnt working. that was before i read it, now that I read it im still confused
duck
duck2d ago
ok so then taking a step back, you will need some means of receiving the interaction the issue with it previously is that on the first line of the execute function, the code returned if it was anything other than a slash command interaction (and message components aren't slash commands) would you want a persistent interactionCreate listener or a collector?
rockers6879
rockers6879OP2d ago
probrably an interaction create listener
duck
duck2d ago
then you will want to add that interactionCreate listener back and make the changes described across the 3 code blocks from the aforementioned guide
rockers6879
rockers6879OP2d ago
duck
duck2d ago
alright then you can respond to the select menu interaction in that if statement for select menus the guide also briefly covers the different methods you can use for responding, but I imagine you'll specifically want to use interaction.reply() which responds to the interaction by sending a new message (it takes nearly the same options as any other message-sending method) tbh I had assumed this article would mention checking custom ids, but just to quickly mention, you can check interaction.customId to differentiate components
d.js docs
d.js docs2d ago
:method: StringSelectMenuInteraction#reply() [email protected] Creates a reply to this interaction. Use the fetchReply option to get the bot's reply message.
// Reply to the interaction and fetch the response
interaction.reply({ content: 'Pong!', fetchReply: true })
.then((message) => console.log(`Reply sent with content ${message.content}`))
.catch(console.error);
// Reply to the interaction and fetch the response
interaction.reply({ content: 'Pong!', fetchReply: true })
.then((message) => console.log(`Reply sent with content ${message.content}`))
.catch(console.error);
:property: MessageComponentInteraction#customId [email protected] The custom id of the component which was interacted with
rockers6879
rockers6879OP2d ago
where exactly would I put this at in the code ? and for the content, can I put the embed name?
duck
duck2d ago
where exactly would I put this at in the code?
putting aside the fact that I mention where to put it in the first line of my previous message, the answer is "you'd put it where you want to reply to an interaction"
and for the content, can I put the embed name?
embeds don't have names, so I'm not totally sure what you mean
rockers6879
rockers6879OP2d ago
i mean like for example its called "rulesEmbed1" can i put that, and alright
duck
duck2d ago
that sounds like you're asking whether you can use a variable you've defined? if that's the part you're struggling with, I'd honestly suggest brushing up on your javascript fundamentals before continuing
rockers6879
rockers6879OP2d ago
oh if its a variable im assuming I can do that? but with the code block you send, i dont understand still. I am extremely sorry, im just not getting this...
duck
duck2d ago
oh if its a variable im assuming I can do that?
it's your rulesEmbed1 I haven't even seen any code that contains this name anywhere, so I'm really unsure what you're referring to
but with the code block you send, i dont understand still
I'm gonna shelve the "you should learn how to read docs" convo for 1 second and mention that if you click the link to actually go to the docs, there's a second example of how to use interaction.reply() that you may be interested in
rockers6879
rockers6879OP2d ago
the variable is in a different spot of code ill look at it aswell
duck
duck2d ago
then once again, I'm gonna suggest brushing up on your javascript fundamentals before continuing particularly scoping
rockers6879
rockers6879OP2d ago
alright I was able to fix it

Did you find this page helpful?