Make a select menu builder for certain roles?

I am kinda new to coding and confused on how I can make a select menu for certain roles. I can get the menu sent but don't know how to make a certain interaction add a certain role.
11 Replies
d.js toolkit
d.js toolkit3mo 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
TÆMBØ
TÆMBØ3mo ago
Discord does not support customizing which roles are shown in a role select menu, so you'll have to use a string select menu in this occasion and call addOptions() to add the options you want into the select menu
Sincerely, alxx ᴬᴳ
ohh, well if I do so then how would I make it so when they select the option it gives it to them?
TÆMBØ
TÆMBØ3mo ago
One way would be to include the role ID in your select menu option value, something like role-menu-1234567890, where you the parse the role ID out of that option's value and then simply call <StringSelectMenuInteraction>.member.roles.add(parsedRoleId)
d.js docs
d.js docs3mo ago
:guide: Message Components: Component interactions read more :property: StringSelectMenuInteraction#values @14.16.3 The values selected
Sincerely, alxx ᴬᴳ
Sorry one last question, what would I replace the <StringSelectMenuInteraction> with?
TÆMBØ
TÆMBØ3mo ago
Your actual StringSelectMenuInteraction you receive, whether that's from a collector or an event listener
d.js docs
d.js docs3mo ago
Explaining <Class> and Class#method notation: learn more
Sincerely, alxx ᴬᴳ
Could you possibly help with the collector or send a doc that explains into more detail about it?
d.js docs
d.js docs3mo ago
:guide: Popular Topics: Collectors - Interaction collectors read more
Sincerely, alxx ᴬᴳ
Thank you!
Want results from more Discord servers?
Add your server