From b6be0160a397ca82da74ddbddc7b406927b22489 Mon Sep 17 00:00:00 2001 From: Eric Yang <64386991+xlq902@users.noreply.github.com> Date: Tue, 12 Apr 2022 00:50:21 -0400 Subject: [PATCH] Update settings.ts --- src/commands/settings.ts | 94 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/src/commands/settings.ts b/src/commands/settings.ts index 78f43c3..2f7dcc4 100644 --- a/src/commands/settings.ts +++ b/src/commands/settings.ts @@ -80,6 +80,100 @@ export async function execute(interaction : CommandInteraction) { break; } case 'subject': { + await interaction.deferReply({ ephemeral: true }); + + const subject = interaction.options.get('subject') ? interaction.options.get('subject')?.value : null; + + let categoryArray : string[] = []; + + let integers = Math.floor((Math.random() * categoryArray.length) + 1); + + switch (subject) { + case null: + categoryArray = ['BIOLOGY', 'PHYSICS', 'CHEMISTRY', 'EARTH AND SPACE', 'ASTRONOMY', 'MATH']; + break; + case 'astro': + case 'astronomy': + categoryArray = ['ASTRONOMY']; + break; + case 'bio': + case 'biology': + categoryArray = ['BIOLOGY']; + break; + case 'ess': + case 'earth science': + case 'es': + categoryArray = ['EARTH SCIENCE']; + break; + case 'chem': + case 'chemistry': + categoryArray = ['CHEMISTRY']; + break; + case 'phys': + case 'physics': + categoryArray = ['PHYSICS']; + break; + case 'math': + categoryArray = ['MATH']; + break; + case 'energy': + categoryArray = ['ENERGY']; + break; + default: + interaction.followUp({ + embeds: [new MessageEmbed() + .setDescription('<:red_x:816791117671825409> Not a valid subject!') + .setColor('#ffffff')], + }); + return; + } + + let h = categoryArray[integers]; //this method may not function because it will sest this once and never change it again until user changes settings? + + const settingsEmbed = new MessageEmbed() + .setColor('#ffffff'); + + const user = interaction.options.getUser('user') || interaction.user; + + const client = interaction.client; + + settingsEmbed + .setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() }) + .setDescription(`selections`); + const menu = new MessageActionRow() + .addComponents( + new MessageSelectMenu() + .setCustomId('select') + .setPlaceholder('Nothing selected') + .addOptions([ + { + label: 'subjects', + description: 'subjects', + value: 'subjects', + }, + { + label: 'gradeLevels', + description: 'grade levels', + value: 'gradeLevels', + }, + ]), + ); + + await interaction.followUp({ embeds: [settingsEmbed], components: [menu] }); + + client.on('interactionCreate', async interaction => { + if (!interaction.isSelectMenu()) return; + var values = interaction.values[0]; + switch(values) { + case 'subjects': + await interaction.update({ content: 'subjects was selected!', components: [] }); + break; + case 'gradeLevels': + await interaction.update({ content: 'levels was selected!', components: [] }); + break; + } + }); + break; } }