diff --git a/bot/awesomescibo.js b/bot/awesomescibo.js
index bb72908..c50be9f 100755
--- a/bot/awesomescibo.js
+++ b/bot/awesomescibo.js
@@ -35,6 +35,14 @@ client.once("ready", () => {
{
"name": "help",
"description": "Replies with a help message explaining what the bot can do"
+ },
+ {
+ "name": "round generate",
+ "description": "Generates a round with randomized questions from https://scibowldb.com/"
+ },
+ {
+ "name": "round list",
+ "description": "Lists your 5 most recently generated rounds with links"
}
]
commandData.forEach(commandData => {
@@ -234,8 +242,8 @@ function sendHelpMessage(interaction) {
);
}
-async function generateRound(message) {
- const generatingMessage = message.channel.send("Generating...");
+async function generateRound(interaction) {
+ const generatingMessage = interaction.reply("Generating...");
let i;
let finalizedHTML = '
ROUND GENERATED BY AWESOMESCIBO USING THE SCIBOWLDB API
';
let tossup_question;
@@ -264,8 +272,8 @@ async function generateRound(message) {
}
newGeneratedRound = new generatedRound({
htmlContent: finalizedHTML,
- requestedBy: message.author.id,
- authorTag: message.author.tag,
+ requestedBy: interaction.author.id,
+ authorTag: interaction.author.tag,
timestamp: new Date().toISOString(),
});
newGeneratedRound.save((err, round) => {
@@ -273,7 +281,7 @@ async function generateRound(message) {
console.log(err);
return;
}
- message.channel.messages.fetch(generatingMessage.id)
+ interaction.channel.messages.fetch(generatingMessage.id)
.then(generatingMessage => {
const msg = generatingMessage.first();
msg.edit(`${message.author}, here's your round: https://api.adawesome.tech/round/${round._id.toString()}`);
@@ -399,11 +407,11 @@ function aboutMessage(message) {
);
}
-async function userRounds(message) {
- let rounds = await generatedRound.find({ requestedBy: message.author.id }).sort({ timestamp: -1 });
+async function userRounds(interaction) {
+ let rounds = await generatedRound.find({ requestedBy: interaction.user.id }).sort({ timestamp: -1 });
let finalMessage = "";
if (!rounds) {
- message.reply("You haven't requested any rounds!");
+ interaction.reply("You haven't requested any rounds!");
return;
}
@@ -421,7 +429,7 @@ async function userRounds(message) {
.setDescription(finalMessage)
.setTimestamp();
- message.channel.send(roundsEmbed);
+ interaction.reply(roundsEmbed);
}
async function hits(message) {
@@ -462,9 +470,6 @@ client.on("message", async (message) => {
if (formattedMessage.startsWith("dobe")) {
// Bot prefix is "do be"
switch (formattedMessage) {
- case "doberoundgen": // Generate round publicly
- generateRound(message);
- break;
case "dobescoring": // Start scoring
startScoring(message);
break;
@@ -483,9 +488,6 @@ client.on("message", async (message) => {
case "dobeabout": // Show about message of bot
aboutMessage(message);
break;
- case "dobemyrounds":
- userRounds(message);
- break;
case "dobehits":
hits(message);
break;
@@ -510,6 +512,12 @@ client.on("interaction", interaction => {
case "train":
training(interaction.options[0] ? interaction.options[0].value : null, interaction);
break;
+ case "round generate":
+ generateRound(interaction);
+ break;
+ case "round list":
+ userRounds(interaction);
+ break;
}
})