I have this command:
if(prefix&&comando === 'gender'||prefix&&comando === 'pronome'){
const embed = new MessageEmbed()
.setColor(config.embed_default_color)
.setTitle('Altere o seu pronome!')
.setDescription('Quando mudá-lo, eu vou te tratar pelo pronome selecionado.')
.addField('Selecione uma opção abaixo.', '- - - - - - - -');
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.addOptions([
{
label: 'Pronome masculino',
value: 'men',
emoji: '🚹'
},
{
label: 'Pronome feminino',
value: 'woman',
emoji: '🚺'
},
{
label: 'Pronome indefinido',
value: 'indef',
emoji: '🟨'
},
]),
);
await message.reply({ embeds: [embed], components: [row] }).then(msg => {
const filtro = (interaction) =>
interaction.isSelectMenu()
const coletor = msg.createMessageComponentCollector({
filtro
});
coletor.on('collect', async (collected) => {
let gn = collected.values[0]
collected.deferUpdate()
if(gn==='men'){
msg.delete();
await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para o masculino, Ele/dele.`);
gender = 'o';
}
else if(gn==='woman'){
msg.delete();
await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para o feminino, Ela/dela.`);
gender = 'a';
}
else if(gn==='men'){
msg.delete();
await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para indefinido.`);
gender = 'x';
}
})
})
}
and below, in the collector(on the if blocks), i have some actions, for when the user select one option in the dropdown menu, the message is sended, but i can't change any variable value there. exists one method to do this? I really need that. Thanks!
Try to follow this guide, it is very complete
Here is an example of how it would be:
const { MessageActionRow, MessageSelectMenu } = require('discord.js');
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'MenuOptions') {
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.setMinValues(2)
.setMaxValues(3)
.addOptions([
{
label: 'Select me',
description: 'This is a description',
value: 'first_option',
},
{
label: 'You can select me too',
description: 'This is also a description',
value: 'second_option',
},
{
label: 'I am also an option',
description: 'This is a description as well',
value: 'third_option',
},
]),
);
await interaction.reply({ content: 'Example!!!!!!!!', components: [row] });
}
});