Users & Role select menu not clearing when it should
I am not sure if this is a bug in discord.js discord it self or me missing something but this seems broken.
I seem to be unable to clear the select when the user has interacted with it, it is possible to clear values set by the bot via setDefaultUsers but as soon as the user selects or deselects something and triggers interactionCreate it becomes impossible to clear it.
I made some code that is able to reproduce this with the following steps
* Enter the token into the TOKEN const
* Start the bot using node
* In any channel which the bot can see and send messages in send
.test
* Select a few users
* Send .test
again
* Press the reset button (the menu should be cleared)
* Select a few users again
* Press the reset button again (No users will be cleared this time even though the same code is being executed)
https://gist.github.com/Jarco-dev/5c6235688ca6cee26bb5a85535c9a1a2Gist
Replication code for bug
Replication code for bug. GitHub Gist: instantly share code, notes, and snippets.
40 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!I am using discord.js 14.14.1 and node.js v18.12.1
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
as in creating new menu's from it?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Okay i am really really confused, both situation below where recorded right after each other with no change in code or even a bot restart in between
the interactionCreate event code used:
When i start off with a empty menu supplied by the bot it doesn't work at all what ever i do
http://i.jarco.dev/eV0umLlC.mp4
But then when i first add some values into the menu and run the command again (so the bot supplies the menu with a few defaults values set) it works perfectly
http://i.jarco.dev/n8yARntO.mp4
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
But how do i update the things i want to change about the components before then?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yes
and the button needs to get disabled when pressing the button
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
the butting disabling works fine just the menu clearing doesn't
but i'll try regardless to try to debug stuff
Trying it in the way you said to makes it not reset in anyway anymore, with the code i had previously it would reset but only in that specific situation which I can't narrow down due you have any clue why it could be that way?
The code i just tried based on what you said (it's a new button cuz it was giving issues and i figured this achives the same anyway)
Honestly i am like 80% sure this is some sort of bug in discord.js where it doesn't send the
default_values: []
to the api somehowUnknown User•11mo ago
Message Not Public
Sign In & Join Server To View
The button works as intended, feel free to try it for your self to replicate
Structures from the API cannot be edited directly. To do so, you can create a new structure (a builder) using the
.from()
method
My issue how ever is not the button it's the menu which i am not disabling just clearing unless it started off with some default values
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Okay, so in the first video it manages to disable the button (as intended) but it does not clear the menu which it should have done so.
But then in the 2nd video when i first select a few things in the menu and then run the command again to get a new menu (which is now populated with default values) the reset button works as intended aka the button gets disabled and the menu gets cleared
So somehow you can't clear the menu if it didn't start off with default values how ever you can clear the menu if it was created with some default values already comming from the bot
and it also only works in this janky way just creating a entire new menu with the builders means it won't even work in the 2nd situation
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
What i mean is that if the menu started empty and i then select a few values i can't clear those values anymore with the bot
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
No, no errors what so ever
infact the button that gets disabled with in the same <Interaction>.update call does actually get disabled
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
This 2nd video is exactly how i want it to function
how ever this functionality is aparently not achievable if the menu didn't start off with some <UserSelectMenuBuilder>.setDeafultUsers() set before sending it
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
How so, shouldn't you be able to remove the selected values via the bot?
because regardless of what it should or shouldn't be currently you can do either one depending on the situation and that doesn't seem right either 🤔
(also i have a idea of how to demonstrate this more clearly I'll change up some code)
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I don't think you understand what i mean with no values selected, I mean that if the menu started empty and the user then selects a few values and you after that try to reset the menu you are not able to clear those selected values.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I've tried that and that doesn't do anything
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
This code gives the same results as in the videos I showed earlier
had to create a entire new menu because referencing the old one didn't work probably because i set the default values on that one else where in the code
I feel like there might be some weird edge case either in discord.js where it doesn't send
default_values: []
to the API in this specific occurance
or a weird edge case on discord's side because i doubt this is intended as that would be very inconsistandUnknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I think i am going to create some code which more clearly demonstrates this and then probably create a issue on discord.js because i feel like people who know how it works internally might know what could be going on
I don’t think the types line up to just resend the received user menu. Have you tried
UserSelectMenuBuilder.from(<component>)
?don't remember if i specificly tried that but i think so, but even in the last example (the code above here) i just recreated the entire menu from scratch and it still didn't do the job
Oh I did see where that wasn’t working. Yeah that should do it.
But yea i think it's some kinda weird edge case thats happening either in discord.js or discord
Managed to narrow down the probably bug further but it sure doesn't make any more sense than it did before
@SpecialSauce @Jô 🌈🦄Figured out the issue, it's a discord client side bug if you restart discord it fixes is so this is upto discord to fix
I have no clue where to check if it's been reported already and if not idk where to report it either