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
- 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!It would just be a message component collector
You can use a collector like above or if it needs to be persistent use the interactionCreate event.
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);
}Looks like you have a handler for interactions. Do you have corresponding menu code for that select menu?
ill show you
What does it do when you use the select menu?
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;
}
}
}
}Looks like this only handles string select menus.
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)Yeah you would have to specify isUserSelectMenu
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 messYou can just add the isUserSelectMenu() to the conditional if it’s in the same selectMenus collection.
i have no idea how to do that lol
If statement needs to be
string select OR user select
so that both types are handled.hahahahahhahaha im lost your too cleaver
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
Chhers i appriciate you so much