Browse Source

Update settings.ts

pull/43/head
Eric Yang 3 years ago
parent
commit
34d0bef112
  1. 111
      src/commands/settings.ts

111
src/commands/settings.ts

@ -6,54 +6,81 @@ import log from '../helpers/log';
export const data = new SlashCommandBuilder() export const data = new SlashCommandBuilder()
.setName('settings') .setName('settings')
.setDescription('BETA - settings configuration'); .setDescription('BETA - settings configuration')
.addSubcommand(subcommand => {
subcommand
.setName('subject')
.setDescription('Changes subject of problems');
return subcommand;
})
.addSubcommand(subcommand => {
subcommand
.setName('gradeLevels')
.setDescription('Changes grade level of problems');
return subcommand;
})
.addSubcommand(subcommand => {
subcommand
.setName('display')
.setDescription('Displays current settings');
return subcommand;
});
export async function execute(interaction : CommandInteraction) { export async function execute(interaction : CommandInteraction) {
await interaction.deferReply(); const action = interaction.options.getSubcommand();
const settingsEmbed = new MessageEmbed() switch (action) {
.setColor('#ffffff'); case 'display': {
await interaction.deferReply({ ephemeral: true });
const settingsEmbed = new MessageEmbed()
.setColor('#ffffff');
const user = interaction.options.getUser('user') || interaction.user; const user = interaction.options.getUser('user') || interaction.user;
const client = interaction.client; const client = interaction.client;
settingsEmbed settingsEmbed
.setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() }) .setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() })
.setDescription(`selections`); .setDescription(`selections`);
const menu = new MessageActionRow() const menu = new MessageActionRow()
.addComponents( .addComponents(
new MessageSelectMenu() new MessageSelectMenu()
.setCustomId('select') .setCustomId('select')
.setPlaceholder('Nothing selected') .setPlaceholder('Nothing selected')
.addOptions([ .addOptions([
{ {
label: 'subjects', label: 'subjects',
description: 'subjects', description: 'subjects',
value: 'subjects', value: 'subjects',
}, },
{ {
label: 'gradeLevels', label: 'gradeLevels',
description: 'grade levels', description: 'grade levels',
value: 'gradeLevels', value: 'gradeLevels',
}, },
]), ]),
); );
await interaction.followUp({ embeds: [settingsEmbed], components: [menu] }); await interaction.followUp({ embeds: [settingsEmbed], components: [menu] });
//everything below this line is bad client.on('interactionCreate', async interaction => {
client.on('interactionCreate', async interaction => { if (!interaction.isSelectMenu()) return;
if (!interaction.isSelectMenu()) return; var values = interaction.values[0];
var values = interaction.values[0]; //potential breaking point switch(values) {
switch(values) { case 'subjects':
case 'subjects': await interaction.update({ content: 'subjects was selected!', components: [] });
await interaction.update({ content: 'subjects was selected!', components: [] }); break;
break; case 'gradeLevels':
case 'gradeLevels': await interaction.update({ content: 'levels was selected!', components: [] });
await interaction.update({ content: 'levels was selected!', components: [] }); break;
break; }
});
break;
} }
}); case 'gradeLevels': {
break;
}
case 'subject': {
break;
}
}
} }
Loading…
Cancel
Save