Does anyone know how to setup userselectmenu listeners?

im stuck as it says interaction failed, im wondering what listeners i need to make or is there one
19 Replies
d.js toolkit
d.js toolkit2y 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!
SpecialSauce
SpecialSauce2y ago
It would just be a message component collector
d.js docs
d.js docs2y ago
guide Popular Topics: Interaction collectors - Basic message component collector read more
SpecialSauce
SpecialSauce2y ago
You can use a collector like above or if it needs to be persistent use the interactionCreate event.
MRParamz
MRParamzOP2y ago
The thing is does it manage it from this? } else if (interaction.isStringSelectMenu()) { const { selectMenus } = client; const { customId } = interaction; const menu = selectMenus.get(customId); if (!menu) return new Error(There is no code for this Menu); try { await menu.execute(interaction, client); } catch (error) { console.error(error); }
SpecialSauce
SpecialSauce2y ago
Looks like you have a handler for interactions. Do you have corresponding menu code for that select menu?
MRParamz
MRParamzOP2y ago
ill show you
SpecialSauce
SpecialSauce2y ago
What does it do when you use the select menu?
MRParamz
MRParamzOP2y ago
nothing but say interaction faled no console log or anything, Here is the handle components code const { readdirSync } = require('fs') module.exports = (client) => { // Initialize the properties in the client object client.buttons = new Map(); client.selectMenus = new Map(); client.modals = new Map(); client.handleComponents = async () => { const componentsFolder = readdirSync(./src/components); for (const folder of componentsFolder) { const componentFiles = readdirSync(./src/components/${folder}).filter(file => file.endsWith('.js')); switch (folder) { case "buttons": for (const file of componentFiles) { const button = require(../components/${folder}/${file}); client.buttons.set(button.data.name, button); } break; case "selectMenus": for (const file of componentFiles) { const menu = require(../components/${folder}/${file}); client.selectMenus.set(menu.data.name, menu); } break; case "modals": for (const file of componentFiles) { const modal = require(../components/${folder}/${file}); client.modals.set(modal.data.name, modal); } break; default: break; } } } }
SpecialSauce
SpecialSauce2y ago
Looks like this only handles string select menus.
MRParamz
MRParamzOP2y ago
When i use select menus i get a error saying : (node:2708) DeprecationWarning: BaseInteraction#isSelectMenu() is deprecated. Use BaseInteraction#isStringSelectMenu() instead. (Use node --trace-deprecation ... to show where the warning was created)
SpecialSauce
SpecialSauce2y ago
Yeah you would have to specify isUserSelectMenu
MRParamz
MRParamzOP2y ago
if i wanna test it do i just change that one bit of code ? : } else if (interaction.isStringSelectMenu()) { const { selectMenus } = client; const { customId } = interaction; const menu = selectMenus.get(customId); if (!menu) return new Error(There is no code for this Menu); try { await menu.execute(interaction, client); } catch (error) { console.error(error); } yes sorry for the hassle so im wondering how i can implument this with the string menus without making a mess
SpecialSauce
SpecialSauce2y ago
You can just add the isUserSelectMenu() to the conditional if it’s in the same selectMenus collection.
MRParamz
MRParamzOP2y ago
i have no idea how to do that lol
SpecialSauce
SpecialSauce2y ago
If statement needs to be string select OR user select so that both types are handled.
MRParamz
MRParamzOP2y ago
hahahahahhahaha im lost your too cleaver
SpecialSauce
SpecialSauce2y ago
If you want it to handle all select menus you should just use isAnySelectMenu(). Id suggest brushing up on conditionals in js if you’re struggling with modifying if statements. #resources
MRParamz
MRParamzOP2y ago
Chhers i appriciate you so much
Want results from more Discord servers?
Add your server