Browse Source

Update to settings.ts

pull/43/head
Eric Yang 3 years ago
parent
commit
8faac8d2bf
  1. 29
      src/commands/settings.ts
  2. 10
      src/events/interactionCreate.ts

29
src/commands/settings.ts

@ -26,17 +26,30 @@ 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: 'Grade Levels',
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] });
const client = interaction.client;
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
var values = interaction.values[1];
switch(values) {
case "subjects":
await interaction.editReply({ content: 'subjects was selected!', components: [] });
break;
case "gradeLevels":
await interaction.editReply({ content: 'levels was selected!', components: [] });
break;
}
});
} }

10
src/events/interactionCreate.ts

@ -4,11 +4,17 @@ export const name = 'interactionCreate';
export const once = false; export const once = false;
declare global {
var client;
}
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;
try { try {
@ -18,4 +24,6 @@ export async function execute(interaction) {
log({ logger: 'interaction', content: `Interaction ${interaction.name} failed!`, level: 'error' }); log({ logger: 'interaction', content: `Interaction ${interaction.name} failed!`, level: 'error' });
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
} }
} //
}

Loading…
Cancel
Save