Interaction Select Menu

Hello i have some code and i have 2 subcommands /setting set and /settings disable First step after selecting one of these is workin (sending selectmenu) and in this again if you choose set everythink is working but with disable for some reason it doesn t see that
20 Replies
d.js toolkit
d.js toolkitthis hour
- 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!
Opzo
OpzoOPthis hour
handleInteraction: async (interaction, client) => {
if (interaction.isStringSelectMenu()) {
const selectedSetting = interaction.values[0];

if (interaction.customId === "settings_disable") {
console.log(`Disabling setting: ${selectedSetting} for guild ${interaction.guild.id}`);
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}

if (interaction.customId === "settings_select") {
let modal = new ModalBuilder().setCustomId(`settings_modal_${selectedSetting}`).setTitle(`Configure ${selectedSetting}`);
handleInteraction: async (interaction, client) => {
if (interaction.isStringSelectMenu()) {
const selectedSetting = interaction.values[0];

if (interaction.customId === "settings_disable") {
console.log(`Disabling setting: ${selectedSetting} for guild ${interaction.guild.id}`);
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}

if (interaction.customId === "settings_select") {
let modal = new ModalBuilder().setCustomId(`settings_modal_${selectedSetting}`).setTitle(`Configure ${selectedSetting}`);
let inputFields = [];

if (["welcome", "leave"].includes(selectedSetting)) {
inputFields = [
{ id: "channel", label: "Channel ID", style: TextInputStyle.Short, required: true },
{ id: "title", label: "Message Title", style: TextInputStyle.Short, required: false },
{ id: "description", label: "Message Description", style: TextInputStyle.Paragraph, required: true },
{ id: "color", label: "Embed Color (hex)", style: TextInputStyle.Short, required: false },
{ id: "imageUrl", label: "Image URL", style: TextInputStyle.Short, required: false },
];
} else if (["associationsChannel", "countingChannel", "lastLetterChannel", "logsChannel", "voiceChannelCreator"].includes(selectedSetting)) {
inputFields = [{ id: "channel", label: "Channel ID", style: TextInputStyle.Short, required: true }];
} else if (["muteRole", "language", "prefix"].includes(selectedSetting)) {
inputFields = [{ id: "value", label: "Enter the value", style: TextInputStyle.Short, required: true }];
} else if (selectedSetting === "partner") {
inputFields = [
{ id: "partnerChannel", label: "Partner Channel ID", style: TextInputStyle.Short, required: true },
{ id: "partnershipRole", label: "Partnership Role ID", style: TextInputStyle.Short, required: true },
{ id: "partnerRole", label: "Partner Role ID", style: TextInputStyle.Short, required: false },
{ id: "partnerPingRole", label: "Partner Ping Role ID", style: TextInputStyle.Short, required: false },
];
}

inputFields.forEach((field) => {
modal.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder().setCustomId(field.id).setLabel(field.label).setStyle(field.style).setRequired(field.required)
)
});

return await interaction.showModal(modal);
}
}
let inputFields = [];

if (["welcome", "leave"].includes(selectedSetting)) {
inputFields = [
{ id: "channel", label: "Channel ID", style: TextInputStyle.Short, required: true },
{ id: "title", label: "Message Title", style: TextInputStyle.Short, required: false },
{ id: "description", label: "Message Description", style: TextInputStyle.Paragraph, required: true },
{ id: "color", label: "Embed Color (hex)", style: TextInputStyle.Short, required: false },
{ id: "imageUrl", label: "Image URL", style: TextInputStyle.Short, required: false },
];
} else if (["associationsChannel", "countingChannel", "lastLetterChannel", "logsChannel", "voiceChannelCreator"].includes(selectedSetting)) {
inputFields = [{ id: "channel", label: "Channel ID", style: TextInputStyle.Short, required: true }];
} else if (["muteRole", "language", "prefix"].includes(selectedSetting)) {
inputFields = [{ id: "value", label: "Enter the value", style: TextInputStyle.Short, required: true }];
} else if (selectedSetting === "partner") {
inputFields = [
{ id: "partnerChannel", label: "Partner Channel ID", style: TextInputStyle.Short, required: true },
{ id: "partnershipRole", label: "Partnership Role ID", style: TextInputStyle.Short, required: true },
{ id: "partnerRole", label: "Partner Role ID", style: TextInputStyle.Short, required: false },
{ id: "partnerPingRole", label: "Partner Ping Role ID", style: TextInputStyle.Short, required: false },
];
}

inputFields.forEach((field) => {
modal.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder().setCustomId(field.id).setLabel(field.label).setStyle(field.style).setRequired(field.required)
)
});

return await interaction.showModal(modal);
}
}
lupus
lupusthis hour
So the settings_disable part isn't working? Where are you setting the custom id for the modal (if that what's supposed to call this)?
Opzo
OpzoOPthis hour
const selectMenu = new StringSelectMenuBuilder()
.setCustomId(subcommand === "set" ? "settings_select" : "settings_disable")
.setPlaceholder(subcommand === "set" ? "Select a setting to configure" : "Select a setting to disable")
.addOptions(settingsOptions);

const row = new ActionRowBuilder().addComponents(selectMenu);
const selectMenu = new StringSelectMenuBuilder()
.setCustomId(subcommand === "set" ? "settings_select" : "settings_disable")
.setPlaceholder(subcommand === "set" ? "Select a setting to configure" : "Select a setting to disable")
.addOptions(settingsOptions);

const row = new ActionRowBuilder().addComponents(selectMenu);
here i give it custom id and it calls this
if (interaction.customId === "settings_disable") {
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}
if (interaction.customId === "settings_disable") {
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}
like it should call this but its not
Opzo
OpzoOPthis hour
when i do with set one:
No description
No description
Opzo
OpzoOPthis hour
and when disable
No description
Opzo
OpzoOPthis hour
oh wait oh discord removes when it fails but i choosed one of option to remove and in console settings_disable doesnt even shows
Opzo
OpzoOPthis hour
No description
Opzo
OpzoOPthis hour
No description
lupus
lupusthis hour
This logs settings_select?
Opzo
OpzoOPthis hour
yeah but settings_disable no
lupus
lupusthis hour
And the select menu has the custom id settings_disable? If so, you mistakenly set it as settings_select somewhere. Or you'll have to explain the flow of the user interaction here.
Opzo
OpzoOPthis hour
ehm
const selectMenu = new StringSelectMenuBuilder()
.setCustomId(subcommand === "set" ? "settings_select" : "settings_disable")
.setPlaceholder(subcommand === "set" ? "Select a setting to configure" : "Select a setting to disable")
.addOptions(settingsOptions);

const row = new ActionRowBuilder().addComponents(selectMenu);
const selectMenu = new StringSelectMenuBuilder()
.setCustomId(subcommand === "set" ? "settings_select" : "settings_disable")
.setPlaceholder(subcommand === "set" ? "Select a setting to configure" : "Select a setting to disable")
.addOptions(settingsOptions);

const row = new ActionRowBuilder().addComponents(selectMenu);
this should be selectMenu and it has settings_select or settings_disable and there is no misatke with names so i will tell 1 one
lupus
lupusthis hour
Then can you log the custom ids of all interactions somewhere? Just to check whether you actually receive it.
Opzo
OpzoOPthis hour
let me see so this will be for /settings set -> menu -> modal
Select Menu Interaction: settings_select [ 'associationsChannel' ]

Modal Submit Interaction: settings_modal_associationsChannel Collection(1) [Map] {
'channel' => { value: 'xd', type: 4, customId: 'channel' }
}
Select Menu Interaction: settings_select [ 'associationsChannel' ]

Modal Submit Interaction: settings_modal_associationsChannel Collection(1) [Map] {
'channel' => { value: 'xd', type: 4, customId: 'channel' }
}
but set works so dont think about this aaand for disable not even console.log i've did /settings disable -> select menu -> used one option (none of them works) -> and discord said that it is not working
lupus
lupusthis hour
And you put the console log right at the top of interactionCreate?
Opzo
OpzoOPthis hour
handleInteraction: async (interaction, client) => {
console.log("Received Interaction:", interaction);

if (interaction.isStringSelectMenu()) {
const selectedSetting = interaction.values[0];
console.log("Select Menu Interaction:", interaction.customId, interaction.values);

if (interaction.customId === "settings_disable") {
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}

if (interaction.customId === "settings_select") {...}
handleInteraction: async (interaction, client) => {
console.log("Received Interaction:", interaction);

if (interaction.isStringSelectMenu()) {
const selectedSetting = interaction.values[0];
console.log("Select Menu Interaction:", interaction.customId, interaction.values);

if (interaction.customId === "settings_disable") {
await client.updateServerSettings(interaction.guild.id, { [selectedSetting]: null });
return await interaction.reply({ content: `✅ Disabled **${selectedSetting}** successfully!`, ephemeral: true });
}

if (interaction.customId === "settings_select") {...}
this way oh you mean whoops OH I FOUND in other file i have only for select
Opzo
OpzoOPthis hour
No description
Opzo
OpzoOPthis hour
okay mb thx
lupus
lupusthis hour
No worries, just mark it as Solved above.

Did you find this page helpful?