Interaction returning undefined

Any idea why my interaction is returning undefined? I can't check if its a select because it is just returning Client:
const { ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, InteractionType, Client, GatewayIntentBits } = require('discord.js');
const config = require('../../../ticketConfig.json');


module.exports = async (interaction) => {
console.log("Interaction received:", interaction);
console.log("Interaction type:", interaction.type);

if (interaction.type !== InteractionType.MessageComponent) {
console.log("Interaction is not a MessageComponent, it's:", interaction.type);
return;
}

if (!(interaction instanceof StringSelectMenuInteraction)) {
console.log("Interaction is not a StringSelectMenuInteraction");
return;
}

if (!interaction.customId.startsWith('select_category_')) {
console.log("Interaction customId does not start with 'select_category_'");
return;
}

console.log("It's a StringSelectMenuInteraction with the correct customId");

const selectedCategory = config.categories.find(category => category.name.toLowerCase() === interaction.values[0]);
if (!selectedCategory) {
console.log("Selected category not found in config");
return;
}

console.log("Selected category found:", selectedCategory.name);

const items = selectedCategory.items.map(item => ({
label: item.name,
value: item.id
}));

const itemMenu = new StringSelectMenuBuilder()
.setCustomId(`select_item_${selectedCategory.name.toLowerCase()}`)
.setPlaceholder('Select an item')
.addOptions(items);

const row = new ActionRowBuilder().addComponents(itemMenu);

await interaction.update({ content: 'Please select an item:', components: [row], ephemeral: true });
};
const { ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, InteractionType, Client, GatewayIntentBits } = require('discord.js');
const config = require('../../../ticketConfig.json');


module.exports = async (interaction) => {
console.log("Interaction received:", interaction);
console.log("Interaction type:", interaction.type);

if (interaction.type !== InteractionType.MessageComponent) {
console.log("Interaction is not a MessageComponent, it's:", interaction.type);
return;
}

if (!(interaction instanceof StringSelectMenuInteraction)) {
console.log("Interaction is not a StringSelectMenuInteraction");
return;
}

if (!interaction.customId.startsWith('select_category_')) {
console.log("Interaction customId does not start with 'select_category_'");
return;
}

console.log("It's a StringSelectMenuInteraction with the correct customId");

const selectedCategory = config.categories.find(category => category.name.toLowerCase() === interaction.values[0]);
if (!selectedCategory) {
console.log("Selected category not found in config");
return;
}

console.log("Selected category found:", selectedCategory.name);

const items = selectedCategory.items.map(item => ({
label: item.name,
value: item.id
}));

const itemMenu = new StringSelectMenuBuilder()
.setCustomId(`select_item_${selectedCategory.name.toLowerCase()}`)
.setPlaceholder('Select an item')
.addOptions(items);

const row = new ActionRowBuilder().addComponents(itemMenu);

await interaction.update({ content: 'Please select an item:', components: [row], ephemeral: true });
};
1 Reply
d.js toolkit
d.js toolkit4mo 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 OP
Want results from more Discord servers?
Add your server