Browse Source

created stable parsing version

pull/43/head
Eric Yang 3 years ago
parent
commit
59e2940c93
  1. 33
      src/commands/settings.ts
  2. 4
      src/events/interactionCreate.ts

33
src/commands/settings.ts

@ -16,9 +16,11 @@ export async function execute(interaction : CommandInteraction) {
const user = interaction.options.getUser('user') || interaction.user;
const client = interaction.client;
settingsEmbed
.setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() })
.setDescription(`a`);
.setDescription(`selections`);
const menu = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
@ -26,17 +28,32 @@ export async function execute(interaction : CommandInteraction) {
.setPlaceholder('Nothing selected')
.addOptions([
{
label: 'Select me',
description: 'This is a description',
value: 'first_option',
label: 'subjects',
description: 'subjects',
value: 'subjects',
},
{
label: 'You can select me too',
description: 'This is also a description',
value: 'second_option',
label: 'gradeLevels',
description: 'grade levels',
value: 'gradeLevels',
},
]),
);
await interaction.followUp({ embeds: [settingsEmbed] });
await interaction.followUp({ embeds: [settingsEmbed], components: [menu] });
//everything below this line is bad
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
var values = interaction.values[0]; //potential breaking point
switch(values) {
case 'subjects':
await interaction.update({ content: 'subjects was selected!', components: [] });
break;
case 'gradeLevels':
await interaction.update({ content: 'levels was selected!', components: [] });
break;
}
});
}

4
src/events/interactionCreate.ts

@ -6,10 +6,12 @@ export const once = false;
export async function execute(interaction) {
const client = interaction.client;
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
if (!command) return; //h
try {
await command.execute(interaction);

Loading…
Cancel
Save