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 });
};
Was this page helpful?