#It happens when I have more than 1

1 messages · Page 1 of 1 (latest)

mental sorrel
#

@rugged verge

rugged verge
#

right

mental sorrel
#

so what should I do

rugged verge
#

are you on a linux machine?

mental sorrel
#

no, windows

rugged verge
#

lemme just paste this here for context

const { options, guild, member } = interaction;
 
let guildData = await Guild.findOne({Guild: guild.id});

let index = 1;
function shopList(name) {
    if (guildData.shop.length) {
        return `${index++}. ${name}`
    }
}

let shopArray = [
    {
        lable: "sussy baka",
        description: "is sus 24/7",
        value: 420
    }
];

let selectMenuThingy = new SelectMenuBuilder()
    .setCustomId('select')
    .setPlaceholder('Nothing selected');

shopArray.forEach(shop => selectMenuThingy.addOptions({
    label: shop.lable,
    description: shop.description,
    value: shop.value
}));


const selectMenu = new ActionRowBuilder().addComponents(selectMenuThingy)
mental sorrel
#

So you have shop.value, but I do not store it in my array

rugged verge
#

what is this "value"?

#

i guessed that you did store it

mental sorrel
#

unfortunately not, I have only this

#

so value is required arg in .addOption()

#

in docs there is an example

#

like first, second option

rugged verge
#

right

#

lemme check the official diacord api docs

mental sorrel
#

alright

rugged verge
#

right

#

so value is used as an identity marker

#
const { options, guild, member } = interaction;
 
let guildData = await Guild.findOne({Guild: guild.id});

let index = 1;
function shopList(name) {
    if (guildData.shop.length) {
        return `${index++}. ${name}`
    }
}

let shopArray = [
    {
        lable: "sussy baka",
        description: "is sus 24/7"
    }
];

let selectMenuThingy = new SelectMenuBuilder()
    .setCustomId('select')
    .setPlaceholder('Nothing selected');

shopArray.forEach(shop => selectMenuThingy.addOptions({
    label: shop.lable,
    description: shop.description,
    value: shop.lable
}));


const selectMenu = new ActionRowBuilder().addComponents(selectMenuThingy)
#

this should work

mental sorrel
#

Thanks

#

works pretty fine

mental sorrel
#

@rugged verge Hello, I have one more question. After user chooses something from this list, how can I get his choice and then do something with it?

rugged verge
#

please read the docs

mental sorrel
#

so I can't for example do

if (selected === 'ping')

#

so I can't get the value

#

of what user has chosen

rugged verge
#

what part of this do you not get

#

@mental sorrel

mental sorrel
#

What you mean