Browse Source

Update settings.ts

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

121
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 user = interaction.options.getUser('user') || interaction.user; const settingsEmbed = new MessageEmbed()
.setColor('#ffffff');
const client = interaction.client;
const user = interaction.options.getUser('user') || interaction.user;
settingsEmbed
.setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() }) const client = interaction.client;
.setDescription(`selections`);
const menu = new MessageActionRow() settingsEmbed
.addComponents( .setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() })
new MessageSelectMenu() .setDescription(`selections`);
.setCustomId('select') const menu = new MessageActionRow()
.setPlaceholder('Nothing selected') .addComponents(
.addOptions([ new MessageSelectMenu()
{ .setCustomId('select')
label: 'subjects', .setPlaceholder('Nothing selected')
description: 'subjects', .addOptions([
value: 'subjects', {
}, label: 'subjects',
{ description: 'subjects',
label: 'gradeLevels', value: 'subjects',
description: 'grade levels', },
value: 'gradeLevels', {
}, label: 'gradeLevels',
]), description: 'grade levels',
); value: 'gradeLevels',
},
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;
}
});
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;
}
case 'gradeLevels': {
break;
}
case 'subject': {
break;
}
}
} }
Loading…
Cancel
Save