Browse Source

Merge branch 'feature-slash-commands' of github.com:ADawesomeguy/AwesomeSciBo into feature-slash-commands

pull/10/head
Abheek Dhawan 4 years ago
parent
commit
d7eda1bf58
  1. 18
      bot/awesomescibo.js

18
bot/awesomescibo.js

@ -58,6 +58,10 @@ client.once("ready", () => {
}
],
"description": "Commands regarding rounds generated by AwesomeSciBo"
},
{
"name": "top",
"description": "Lists top ten scores across servers (server specific leaderboard WIP)"
}
]);
@ -333,7 +337,7 @@ async function showIssLocation(message) {
});
}
function showLeaderboard(message) {
function showLeaderboard(interaction) {
let messageContent = "";
userScore
.find({})
@ -341,20 +345,20 @@ function showLeaderboard(message) {
.exec((err, obj) => {
if (err) {
console.log(err);
return message.reply(
return interaction.reply(
"Uh oh! :( There was an internal error. Please try again."
);
}
if (obj.length < 10) {
// Need at least 10 scores for top 10
return message.reply(
return interaction.reply(
`There are only ${obj.length} users, we need at least 10!`
);
}
for (let i = 0; i < 10; i++) {
messageContent += `${i + 1}: <@${obj[i].authorID}>: ${obj[i].score}\n`; // Loop through each user and add their name and score to leaderboard content
}
message.channel.send(
interaction.reply(
new Discord.MessageEmbed()
.setTitle("Top Ten!")
.setDescription(messageContent)
@ -488,9 +492,6 @@ client.on("message", async (message) => {
case "dobescoring": // Start scoring
startScoring(message);
break;
case "dobetop": // Top 10 scores
showLeaderboard(message);
break;
case "dobehappy": // Send happy message
dontWorryBeHappy(message);
break;
@ -524,6 +525,9 @@ client.on("interaction", interaction => {
case "rounds":
rounds(interaction.options[0].name, interaction);
break;
case "top":
showLeaderboard(interaction);
break;
}
})

Loading…
Cancel
Save