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 user = interaction.options.getUser('user') || interaction.user;
const client = interaction.client;
settingsEmbed settingsEmbed
.setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() }) .setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() })
.setDescription(`a`); .setDescription(`selections`);
const menu = new MessageActionRow() const menu = new MessageActionRow()
.addComponents( .addComponents(
new MessageSelectMenu() new MessageSelectMenu()
@ -26,17 +28,32 @@ export async function execute(interaction : CommandInteraction) {
.setPlaceholder('Nothing selected') .setPlaceholder('Nothing selected')
.addOptions([ .addOptions([
{ {
label: 'Select me', label: 'subjects',
description: 'This is a description', description: 'subjects',
value: 'first_option', value: 'subjects',
}, },
{ {
label: 'You can select me too', label: 'gradeLevels',
description: 'This is also a description', description: 'grade levels',
value: 'second_option', 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) { export async function execute(interaction) {
const client = interaction.client; const client = interaction.client;
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName); const command = client.commands.get(interaction.commandName);
if (!command) return;
if (!command) return; //h
try { try {
await command.execute(interaction); await command.execute(interaction);

Loading…
Cancel
Save