|
@ -35,6 +35,14 @@ client.once("ready", () => { |
|
|
{ |
|
|
{ |
|
|
"name": "help", |
|
|
"name": "help", |
|
|
"description": "Replies with a help message explaining what the bot can do" |
|
|
"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 => { |
|
|
commandData.forEach(commandData => { |
|
@ -234,8 +242,8 @@ function sendHelpMessage(interaction) { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function generateRound(message) { |
|
|
async function generateRound(interaction) { |
|
|
const generatingMessage = message.channel.send("Generating..."); |
|
|
const generatingMessage = interaction.reply("Generating..."); |
|
|
let i; |
|
|
let i; |
|
|
let finalizedHTML = '<html><head><link rel="preconnect" href="https://fonts.gstatic.com"><link href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap" rel="stylesheet"> </head><body style="width: 70%; margin-left: auto; margin-right: auto;"><h2 style="text-align: center; text-decoration: underline overline; padding: 7px;">ROUND GENERATED BY AWESOMESCIBO USING THE SCIBOWLDB API</h2>'; |
|
|
let finalizedHTML = '<html><head><link rel="preconnect" href="https://fonts.gstatic.com"><link href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap" rel="stylesheet"> </head><body style="width: 70%; margin-left: auto; margin-right: auto;"><h2 style="text-align: center; text-decoration: underline overline; padding: 7px;">ROUND GENERATED BY AWESOMESCIBO USING THE SCIBOWLDB API</h2>'; |
|
|
let tossup_question; |
|
|
let tossup_question; |
|
@ -264,8 +272,8 @@ async function generateRound(message) { |
|
|
} |
|
|
} |
|
|
newGeneratedRound = new generatedRound({ |
|
|
newGeneratedRound = new generatedRound({ |
|
|
htmlContent: finalizedHTML, |
|
|
htmlContent: finalizedHTML, |
|
|
requestedBy: message.author.id, |
|
|
requestedBy: interaction.author.id, |
|
|
authorTag: message.author.tag, |
|
|
authorTag: interaction.author.tag, |
|
|
timestamp: new Date().toISOString(), |
|
|
timestamp: new Date().toISOString(), |
|
|
}); |
|
|
}); |
|
|
newGeneratedRound.save((err, round) => { |
|
|
newGeneratedRound.save((err, round) => { |
|
@ -273,7 +281,7 @@ async function generateRound(message) { |
|
|
console.log(err); |
|
|
console.log(err); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
message.channel.messages.fetch(generatingMessage.id) |
|
|
interaction.channel.messages.fetch(generatingMessage.id) |
|
|
.then(generatingMessage => { |
|
|
.then(generatingMessage => { |
|
|
const msg = generatingMessage.first(); |
|
|
const msg = generatingMessage.first(); |
|
|
msg.edit(`${message.author}, here's your round: https://api.adawesome.tech/round/${round._id.toString()}`); |
|
|
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) { |
|
|
async function userRounds(interaction) { |
|
|
let rounds = await generatedRound.find({ requestedBy: message.author.id }).sort({ timestamp: -1 }); |
|
|
let rounds = await generatedRound.find({ requestedBy: interaction.user.id }).sort({ timestamp: -1 }); |
|
|
let finalMessage = ""; |
|
|
let finalMessage = ""; |
|
|
if (!rounds) { |
|
|
if (!rounds) { |
|
|
message.reply("You haven't requested any rounds!"); |
|
|
interaction.reply("You haven't requested any rounds!"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -421,7 +429,7 @@ async function userRounds(message) { |
|
|
.setDescription(finalMessage) |
|
|
.setDescription(finalMessage) |
|
|
.setTimestamp(); |
|
|
.setTimestamp(); |
|
|
|
|
|
|
|
|
message.channel.send(roundsEmbed); |
|
|
interaction.reply(roundsEmbed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function hits(message) { |
|
|
async function hits(message) { |
|
@ -462,9 +470,6 @@ client.on("message", async (message) => { |
|
|
if (formattedMessage.startsWith("dobe")) { |
|
|
if (formattedMessage.startsWith("dobe")) { |
|
|
// Bot prefix is "do be"
|
|
|
// Bot prefix is "do be"
|
|
|
switch (formattedMessage) { |
|
|
switch (formattedMessage) { |
|
|
case "doberoundgen": // Generate round publicly
|
|
|
|
|
|
generateRound(message); |
|
|
|
|
|
break; |
|
|
|
|
|
case "dobescoring": // Start scoring
|
|
|
case "dobescoring": // Start scoring
|
|
|
startScoring(message); |
|
|
startScoring(message); |
|
|
break; |
|
|
break; |
|
@ -483,9 +488,6 @@ client.on("message", async (message) => { |
|
|
case "dobeabout": // Show about message of bot
|
|
|
case "dobeabout": // Show about message of bot
|
|
|
aboutMessage(message); |
|
|
aboutMessage(message); |
|
|
break; |
|
|
break; |
|
|
case "dobemyrounds": |
|
|
|
|
|
userRounds(message); |
|
|
|
|
|
break; |
|
|
|
|
|
case "dobehits": |
|
|
case "dobehits": |
|
|
hits(message); |
|
|
hits(message); |
|
|
break; |
|
|
break; |
|
@ -510,6 +512,12 @@ client.on("interaction", interaction => { |
|
|
case "train": |
|
|
case "train": |
|
|
training(interaction.options[0] ? interaction.options[0].value : null, interaction); |
|
|
training(interaction.options[0] ? interaction.options[0].value : null, interaction); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "round generate": |
|
|
|
|
|
generateRound(interaction); |
|
|
|
|
|
break; |
|
|
|
|
|
case "round list": |
|
|
|
|
|
userRounds(interaction); |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|