String Collectors not Collecting?

// User interaction - Add Line Item Button
if (newOrderButtons.customId === 'addlineitem') {
// Log start newOrder type select
console.log('[newOrder] Started newOrder Type Select');

// Define ticket types
const facTicketTypes = [
{
label: 'Material',
description: 'Facility materials',
value: 'material',
},
{
label: 'TrainEco',
description: 'Trains for large rails',
value: 'train',
},
{
label: 'Naval',
description: 'Large ships',
value: 'naval',
},
{
label: 'BTEco',
description: 'Battle tanks',
value: 'BT',
},
{
label: 'Upgrade',
description: 'Vehicle upgrade',
value: 'upgrade',
},
{
label: 'Other',
description: 'Other ticket',
value: 'other',
},
]

// Build ticketType SelectMenu
console.log('[newOrder] Build ticketType SelectMenu');
const ticketType = new StringSelectMenuBuilder()
.setCustomId('ticketTypeSelectMenu')
.setPlaceholder('Make a selection')
//.setMinValues(0)
//.setMaxValues(facTicketTypes.length)
.addOptions(facTicketTypes.map((facTicketTypes) =>
new StringSelectMenuOptionBuilder()
.setLabel(facTicketTypes.label)
.setDescription(facTicketTypes.description)
.setValue(facTicketTypes.value)
));

console.log('[newOrder] Build ticketTypeRow');
const ticketTypeRow = new ActionRowBuilder()
.addComponents(ticketType);

// Display SelectMenu
console.log('[newOrder] Display ticket type StringSelect');
const newTicketTypeResponse = await newOrderButtons.reply({
content: 'Select Ticket Type',
components: [ticketTypeRow],
ephemeral: true,
});
// User interaction - Add Line Item Button
if (newOrderButtons.customId === 'addlineitem') {
// Log start newOrder type select
console.log('[newOrder] Started newOrder Type Select');

// Define ticket types
const facTicketTypes = [
{
label: 'Material',
description: 'Facility materials',
value: 'material',
},
{
label: 'TrainEco',
description: 'Trains for large rails',
value: 'train',
},
{
label: 'Naval',
description: 'Large ships',
value: 'naval',
},
{
label: 'BTEco',
description: 'Battle tanks',
value: 'BT',
},
{
label: 'Upgrade',
description: 'Vehicle upgrade',
value: 'upgrade',
},
{
label: 'Other',
description: 'Other ticket',
value: 'other',
},
]

// Build ticketType SelectMenu
console.log('[newOrder] Build ticketType SelectMenu');
const ticketType = new StringSelectMenuBuilder()
.setCustomId('ticketTypeSelectMenu')
.setPlaceholder('Make a selection')
//.setMinValues(0)
//.setMaxValues(facTicketTypes.length)
.addOptions(facTicketTypes.map((facTicketTypes) =>
new StringSelectMenuOptionBuilder()
.setLabel(facTicketTypes.label)
.setDescription(facTicketTypes.description)
.setValue(facTicketTypes.value)
));

console.log('[newOrder] Build ticketTypeRow');
const ticketTypeRow = new ActionRowBuilder()
.addComponents(ticketType);

// Display SelectMenu
console.log('[newOrder] Display ticket type StringSelect');
const newTicketTypeResponse = await newOrderButtons.reply({
content: 'Select Ticket Type',
components: [ticketTypeRow],
ephemeral: true,
});
18 Replies
d.js toolkit
d.js toolkit5w 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!
ShockZone
ShockZone5w ago
// ***************************************
// New Order - New Line StringSelect Response
// ***************************************

const collectorFilter = i => i.user.id === newTicketTypeResponse.user.id;


// Wait for user input
console.log('[mewOrder] Waiting for user input - ticket type');
const ticketTypeSelection = await newTicketTypeResponse.awaitMessageComponent({
});

ticketTypeSelection.on('collect', async newTicketType => {
const selection = newTicketType.values[0];
await newTicketType.reply(`${newTicketType.user} has selected ${selection}!`)
});


console.log(ticketTypeSelection);

ticketTypeSelection.on('collect', async (newTicketType) => {

// Log ticket type chosen

if (ticketTypeSelection.values == 'material') {
console.log('[newOrder] User has chosen material ticket');
}
})
// ***************************************
// New Order - New Line StringSelect Response
// ***************************************

const collectorFilter = i => i.user.id === newTicketTypeResponse.user.id;


// Wait for user input
console.log('[mewOrder] Waiting for user input - ticket type');
const ticketTypeSelection = await newTicketTypeResponse.awaitMessageComponent({
});

ticketTypeSelection.on('collect', async newTicketType => {
const selection = newTicketType.values[0];
await newTicketType.reply(`${newTicketType.user} has selected ${selection}!`)
});


console.log(ticketTypeSelection);

ticketTypeSelection.on('collect', async (newTicketType) => {

// Log ticket type chosen

if (ticketTypeSelection.values == 'material') {
console.log('[newOrder] User has chosen material ticket');
}
})
The console logs run all the way through "Waiting for user input - ticket type", but have zero interest in actually running the collector on list selection. Even more interesting (for me), is that I'm collecting the 'material' choice
treble/luna
treble/luna5w ago
add fetchReply: true when replying
ShockZone
ShockZone5w ago
Explain it like I know nothing?
d.js docs
d.js docs5w ago
:propertysignature: InteractionReplyOptions#fetchReply @14.15.3 Whether to fetch the reply
ShockZone
ShockZone5w ago
is that in here?
const newTicketTypeResponse = await newOrderButtons.reply({
content: 'Select Ticket Type',
components: [ticketTypeRow],
ephemeral: true,
const newTicketTypeResponse = await newOrderButtons.reply({
content: 'Select Ticket Type',
components: [ticketTypeRow],
ephemeral: true,
treble/luna
treble/luna5w ago
yes
ShockZone
ShockZone5w ago
Ah, so that basically removes the need for a collector using awaitMessageComponent
treble/luna
treble/luna5w ago
no
ShockZone
ShockZone5w ago
I guess I meant the .on('collect') bit. The response I'm now getting is an obejct, and I can pull the .values from it and keep executing
treble/luna
treble/luna5w ago
that response is your interaction
ShockZone
ShockZone5w ago
Thank you Followup question... What does this do to execution? The next line is an if that isn't executing. I even threw in an else whose only action is console.log('If failed') Naturally I'm getting If failed
duck
duck5w ago
fetchReply: true just fetches the Message your bot replies with without it, reply resolves in an InteractionResponse currently there are a few issues with collectors created from InteractionResponses, so adding fetchReply: true sidesteps this this would be unrelated to your if statement frankly it's a little confusing how your code has executed without errors so far
const ticketTypeSelection = await newTicketTypeResponse.awaitMessageComponent({ ticketTypeSelection.on('collect', async newTicketType => {
this should error since awaitMessageComponent doesn't resolve in an InteractionCollector, just the MessageComponentInteraction, and <MessageComponentInteraction>.on() doesn't exist I have to assume this isn't exactly the code that's executing, so please share your updated code
ShockZone
ShockZone5w ago
No description
Want results from more Discord servers?
Add your server