StringSelectMenu interaction isnt working

else if(interaction.isStringSelectMenu()) // String Select Menu Interactions
{
const role = interaction.guild.roles.cache.get(ROLE_IDS[interaction.customId.toUpperCase()]);

if(role)
{
const hasRole = interaction.member.roles.cache.has(role.id);

if(hasRole)
return interaction.member.roles
.remove(role)
.then((member) =>
interaction.reply(
{
embeds: [EMBEDS.ROLE_REMOVED],
ephemeral: true,
})
)
.catch((err) =>
{
console.log(err);
return interaction.reply(
{
embeds: [EMBEDS.ERROR],
ephemeral: true,
});
});
else
return interaction.member.roles
.add(role)
.then((member) =>
interaction.reply(
{
embeds: [EMBEDS.ROLE_ADDED],
ephemeral: true,
})
)
.catch((err) =>
{
console.log(err);
return interaction.reply(
{
embeds: [EMBEDS.ERROR],
ephemeral: true,
});
});
}
}
else if(interaction.isStringSelectMenu()) // String Select Menu Interactions
{
const role = interaction.guild.roles.cache.get(ROLE_IDS[interaction.customId.toUpperCase()]);

if(role)
{
const hasRole = interaction.member.roles.cache.has(role.id);

if(hasRole)
return interaction.member.roles
.remove(role)
.then((member) =>
interaction.reply(
{
embeds: [EMBEDS.ROLE_REMOVED],
ephemeral: true,
})
)
.catch((err) =>
{
console.log(err);
return interaction.reply(
{
embeds: [EMBEDS.ERROR],
ephemeral: true,
});
});
else
return interaction.member.roles
.add(role)
.then((member) =>
interaction.reply(
{
embeds: [EMBEDS.ROLE_ADDED],
ephemeral: true,
})
)
.catch((err) =>
{
console.log(err);
return interaction.reply(
{
embeds: [EMBEDS.ERROR],
ephemeral: true,
});
});
}
}
8 Replies
d.js toolkit
d.js toolkit7mo 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!
SuperPEKKA336
SuperPEKKA3367mo ago
when i select something in the select menu, it nothing happens oh
d.js docs
d.js docs7mo ago
SuperPEKKA336
SuperPEKKA3367mo ago
i just used the same thing from my isButton event ah gotcha thats why the row has one item in it how would i get the value from a select menu? also you can select multiple not just one thx if it returns an array whats teh best way to give the roles for each selected ok wait how
d.js docs
d.js docs7mo ago
method GuildMemberRoleManager#add() Adds a role (or multiple roles) to the member.
SuperPEKKA336
SuperPEKKA3367mo ago
oh but what if someone wants to remove a role i tried doing a for loop to cycle through the array for(array[i]) { if user has role add if user doesnt have role remove }
SuperPEKKA336
SuperPEKKA3367mo ago
basically you can select what games you play
No description
SuperPEKKA336
SuperPEKKA3367mo ago
ah but if you per say have choice A already and then you open the menu and remove choice A but add Choice B and C the .add(array) it would add everything selected right? oh does the menu reset every time you use it? liek the check marks dont show what you have selected previously? nautrally yeah especially if you use more than one device ill choose the former so ill wipe all the current roles in the menu that the user already has and add what they select ^ bad phrasing removes the roles that the menu offers removes any existing roles that are option 1 - 9 and adds the roels selcted so basically when they select the roles they want in the menu
for() // removes all existing roles 1-9
if(user.hasRole)
remove(role)

user.add([roles])
for() // removes all existing roles 1-9
if(user.hasRole)
remove(role)

user.add([roles])
well the roels that they will have will just be what they select so every time they use teh menu the roles they select are the roels that they will have how im only removing the specified roles im not removing ALL their roles just the specified roels Ohhhh Gotcha so basically i set the roles to a set list
interaction.roles.set([roles])
interaction.roles.set([roles])