ShockZone
DIAdiscord.js - Imagine an app
•Created by ShockZone on 8/14/2024 in #djs-questions
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,
});
23 replies