diff --git a/src/commands/rounds.ts b/src/commands/rounds.ts
index e3c5f21..564cebf 100644
--- a/src/commands/rounds.ts
+++ b/src/commands/rounds.ts
@@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, CommandInteraction } from 'discord.js';
import axios from 'axios';
@@ -28,24 +28,24 @@ export const data = new SlashCommandBuilder()
return subcommand;
});
-export async function execute(interaction) {
- await interaction.deferReply();
-
+export async function execute(interaction : CommandInteraction) {
const action = interaction.options.getSubcommand();
- if (action === 'generate') {
- let i;
+ switch (action) {
+ case 'generate': {
+ interaction.deferReply({ ephemeral: true });
+
let finalizedHTML = '
ROUND GENERATED BY AWESOMESCIBO USING THE SCIBOWLDB API
';
- let tossup_question;
- let question_category;
- let tossup_format;
- let tossup_answer;
- let bonus_question;
- let bonus_format;
- let bonus_answer;
+ let tossup_question : string;
+ let question_category : string;
+ let tossup_format : string;
+ let tossup_answer : string;
+ let bonus_question : string;
+ let bonus_format : string;
+ let bonus_answer : string;
let htmlContent = '';
await axios.post('https://scibowldb.com/api/questions', { categories: ['BIOLOGY', 'PHYSICS', 'CHEMISTRY', 'EARTH AND SPACE', 'ASTRONOMY', 'MATH'] })
.then((response) => {
- for (i = 1; i < 26; i++) {
+ for (let i = 1; i < 26; i++) {
const questionData = response.data.questions[Math.floor(Math.random() * response.data.questions.length)];
tossup_question = questionData.tossup_question;
tossup_answer = questionData.tossup_answer;
@@ -72,15 +72,19 @@ export async function execute(interaction) {
log({ logger: 'rounds', content: `Saving round to DB failed: ${err}`, level: 'error' });
return;
}
- interaction.followUp(`Here's your round: https://api.adawesome.tech/round/${round._id.toString()}`, { ephemeral: true });
+ interaction.followUp({ content: `Here's your round: https://api.adawesome.tech/round/${round._id.toString()}`, ephemeral: true });
});
});
+ break;
}
- else if (action === 'list') {
+
+ case 'list': {
+ interaction.deferReply({ ephemeral: true });
+
let roundsList = await generatedRound.find({ requestedBy: interaction.user.id }).sort({ timestamp: -1 });
let finalMessage = '';
if (!roundsList) {
- interaction.followUp('You haven\'t requested any roundsList!');
+ interaction.followUp('You haven\'t requested any rounds!');
return;
}
@@ -94,7 +98,7 @@ export async function execute(interaction) {
const roundsListEmbed = new MessageEmbed()
.setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() })
- .setTitle('Last 5 Rounds Requested')
+ .setTitle('Last 5 rounds requested')
.setDescription(finalMessage)
.setTimestamp();
@@ -102,11 +106,17 @@ export async function execute(interaction) {
embeds: [roundsListEmbed],
ephemeral: true,
});
+ break;
}
- else if (action === 'hit') {
+
+ case 'hit': {
+ await interaction.deferReply();
+
const totalCount = await generatedRound.countDocuments({});
const userCount = await generatedRound.countDocuments({ requestedBy: interaction.user.id });
interaction.followUp(`Total Hits: ${totalCount}\nYour Hits: ${userCount}`);
+ break;
+ }
}
}
\ No newline at end of file