Problem with ChannelSelectMenuBuilder

THis are my options for it:
new ChannelSelectMenuBuilder()
.setCustomId('select-ticket-category-dropdown')
.setPlaceholder('Select a category')
.setMinValues(1)
.setMaxValues(1)
.setChannelTypes(ChannelType.GuildCategory)
new ChannelSelectMenuBuilder()
.setCustomId('select-ticket-category-dropdown')
.setPlaceholder('Select a category')
.setMinValues(1)
.setMaxValues(1)
.setChannelTypes(ChannelType.GuildCategory)
so when i click the select menu and pic a category, it just returns an error this error below:
2023-12-10 13:15:02 - ERROR - Encountered error on event listener "CoreInteractionCreate" for event "interactionCreate" at path "::virtual::" TypeError: Cannot read properties of undefined (reading 'match')
2023-12-10 13:15:02 - ERROR - at Object.ok (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/InteractionHandlerStore.cjs:26:18)
2023-12-10 13:15:02 - ERROR - at _ResultOk.match (/workspaces/saber-chan/node_modules/@sapphire/result/dist/cjs/index.cjs:151:21)
2023-12-10 13:15:02 - ERROR - at _InteractionHandlerStore.run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/InteractionHandlerStore.cjs:23:16)
2023-12-10 13:15:02 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-10 13:15:02 - ERROR - at async _CoreListener.run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/listeners/CoreInteractionCreate.cjs:21:7)
2023-12-10 13:15:02 - ERROR - at async Object.fromAsync (/workspaces/saber-chan/node_modules/@sapphire/result/dist/cjs/index.cjs:619:22)
2023-12-10 13:15:02 - ERROR - at async _CoreListener._run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:22)
2023-12-10 13:15:02 - ERROR - Encountered error on event listener "CoreInteractionCreate" for event "interactionCreate" at path "::virtual::" TypeError: Cannot read properties of undefined (reading 'match')
2023-12-10 13:15:02 - ERROR - at Object.ok (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/InteractionHandlerStore.cjs:26:18)
2023-12-10 13:15:02 - ERROR - at _ResultOk.match (/workspaces/saber-chan/node_modules/@sapphire/result/dist/cjs/index.cjs:151:21)
2023-12-10 13:15:02 - ERROR - at _InteractionHandlerStore.run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/InteractionHandlerStore.cjs:23:16)
2023-12-10 13:15:02 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-10 13:15:02 - ERROR - at async _CoreListener.run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/listeners/CoreInteractionCreate.cjs:21:7)
2023-12-10 13:15:02 - ERROR - at async Object.fromAsync (/workspaces/saber-chan/node_modules/@sapphire/result/dist/cjs/index.cjs:619:22)
2023-12-10 13:15:02 - ERROR - at async _CoreListener._run (/workspaces/saber-chan/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:22)
2 Replies
Lioness100
Lioness1006mo ago
Are you sure the error is coming from that builder? From the stack trace, it looks like you might've forgotten to return this.some(...) or this.none() from your interaction handler's parse function. Please send more of your code.
KAS
KAS6mo ago
slr, i just woke up, anyways this is my full code below:
const {
InteractionHandler,
InteractionHandlerTypes,
container
} = require('@sapphire/framework');
const { EmbedBuilder } = require('discord.js');

module.exports = class SelectTicketCategory extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.SelectMenu
});
}

async run(interaction, result) {
try {
await interaction.update({
embeds: [result.data.embed]
});
} catch (err) {
console.log(err)
}
}

getSetupPanelMenu(id) {
return container.setupPanelMenu.find(item => item.setupSessionId === id);
}

async parse(interaction) {
if (interaction.customId !== 'select-ticket-category-dropdown') return this.none();

const messageId = interaction.message.id;
console.log(interaction.values)
const selectedCategory = interaction.values[0];
(container.setupPanelMenu.find(item => item.setupSessionId === messageId)).ticketCategory = selectedCategory;

const preSaveTicketCategory = this.getSetupPanelMenu(messageId).ticketCategory;

const colelctionEmbed = new EmbedBuilder(interaction.message.embeds[0].data)
.setFields(
{ name: '> > Selected Category <', value: preSaveTicketCategory === null ? 'Selecting...' : `<#${preSaveTicketCategory}>`, inline: false }
);

return this.some({ data: { embed: colelctionEmbed } });
}
}
const {
InteractionHandler,
InteractionHandlerTypes,
container
} = require('@sapphire/framework');
const { EmbedBuilder } = require('discord.js');

module.exports = class SelectTicketCategory extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.SelectMenu
});
}

async run(interaction, result) {
try {
await interaction.update({
embeds: [result.data.embed]
});
} catch (err) {
console.log(err)
}
}

getSetupPanelMenu(id) {
return container.setupPanelMenu.find(item => item.setupSessionId === id);
}

async parse(interaction) {
if (interaction.customId !== 'select-ticket-category-dropdown') return this.none();

const messageId = interaction.message.id;
console.log(interaction.values)
const selectedCategory = interaction.values[0];
(container.setupPanelMenu.find(item => item.setupSessionId === messageId)).ticketCategory = selectedCategory;

const preSaveTicketCategory = this.getSetupPanelMenu(messageId).ticketCategory;

const colelctionEmbed = new EmbedBuilder(interaction.message.embeds[0].data)
.setFields(
{ name: '> > Selected Category <', value: preSaveTicketCategory === null ? 'Selecting...' : `<#${preSaveTicketCategory}>`, inline: false }
);

return this.some({ data: { embed: colelctionEmbed } });
}
}
so it update the embed but it still giving the error