Browse Source

Made subcommands do actual stuff

pull/43/head
Eric Yang 3 years ago
parent
commit
ce2f8d5bf9
  1. 156
      src/commands/settings.ts

156
src/commands/settings.ts

@ -77,59 +77,7 @@ export async function execute(interaction : CommandInteraction) {
break; break;
} }
case 'gradeLevels': { case 'gradeLevels': {
break;
}
case 'subject': {
await interaction.deferReply({ ephemeral: true }); 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() const settingsEmbed = new MessageEmbed()
.setColor('#ffffff'); .setColor('#ffffff');
@ -176,5 +124,109 @@ export async function execute(interaction : CommandInteraction) {
break; break;
} }
case 'subject': {
await interaction.deferReply({ ephemeral: true });
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(`Current subject settings: `);
const menu = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.addOptions([
{
label: 'All',
description: 'All subjects: astronomy, biology, earth science, chemistry, physics, mathematics, and energy',
value: 'potpourri',
},
{
label: 'Astronomy',
description: 'Astronomy',
value: 'astro',
},
{
label: 'Biology',
description: 'Biology',
value: 'bio',
},
{
label: 'Earth Science',
description: 'Earth Science',
value: 'es',
},
{
label: 'Chemistry',
description: 'Chemistry',
value: 'chem',
},
{
label: 'Physics',
description: 'Physics',
value: 'phy',
},
{
label: 'Mathematics',
description: 'Mathematics',
value: 'math',
},
{
label: 'Energy',
description: 'Energy',
value: 'energy',
}
]),
);
await interaction.followUp({ embeds: [settingsEmbed], components: [menu] });
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
var values = interaction.values[0];
switch(values) {
case 'potpourri':
//everything stuff
await interaction.update({ content: 'Subject set to: everything', components: [] });
break;
case 'astro':
//astronomy stuff
await interaction.update({ content: 'Subject set to: astronomy', components: [] });
break;
case 'bio':
//biology stuff
await interaction.update({ content: 'Subject set to: biology', components: [] });
break;
case 'es':
//earth science stuff
await interaction.update({ content: 'Subject set to: earth science', components: [] });
break;
case 'chem':
//chemistry stuff
await interaction.update({ content: 'Subject set to: chemistry', components: [] });
break;
case 'phy':
//physics stuff
await interaction.update({ content: 'Subject set to: physics', components: [] });
break;
case 'math':
//math stuff
await interaction.update({ content: 'Subject set to: mathematics', components: [] });
break;
case 'energy':
//the united states department of energy is a cabinet-level agency responsible for the creation and management of...
await interaction.update({ content: 'Subject set to: energy', components: [] });
break;
}
});
break;
}
} }
} }
Loading…
Cancel
Save