|
@ -58,6 +58,10 @@ client.once("ready", () => { |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
"description": "Commands regarding rounds generated by AwesomeSciBo" |
|
|
"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 = ""; |
|
|
let messageContent = ""; |
|
|
userScore |
|
|
userScore |
|
|
.find({}) |
|
|
.find({}) |
|
@ -341,20 +345,20 @@ function showLeaderboard(message) { |
|
|
.exec((err, obj) => { |
|
|
.exec((err, obj) => { |
|
|
if (err) { |
|
|
if (err) { |
|
|
console.log(err); |
|
|
console.log(err); |
|
|
return message.reply( |
|
|
return interaction.reply( |
|
|
"Uh oh! :( There was an internal error. Please try again." |
|
|
"Uh oh! :( There was an internal error. Please try again." |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
if (obj.length < 10) { |
|
|
if (obj.length < 10) { |
|
|
// Need at least 10 scores for top 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!` |
|
|
`There are only ${obj.length} users, we need at least 10!` |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < 10; i++) { |
|
|
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
|
|
|
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() |
|
|
new Discord.MessageEmbed() |
|
|
.setTitle("Top Ten!") |
|
|
.setTitle("Top Ten!") |
|
|
.setDescription(messageContent) |
|
|
.setDescription(messageContent) |
|
@ -488,9 +492,6 @@ client.on("message", async (message) => { |
|
|
case "dobescoring": // Start scoring
|
|
|
case "dobescoring": // Start scoring
|
|
|
startScoring(message); |
|
|
startScoring(message); |
|
|
break; |
|
|
break; |
|
|
case "dobetop": // Top 10 scores
|
|
|
|
|
|
showLeaderboard(message); |
|
|
|
|
|
break; |
|
|
|
|
|
case "dobehappy": // Send happy message
|
|
|
case "dobehappy": // Send happy message
|
|
|
dontWorryBeHappy(message); |
|
|
dontWorryBeHappy(message); |
|
|
break; |
|
|
break; |
|
@ -524,6 +525,9 @@ client.on("interaction", interaction => { |
|
|
case "rounds": |
|
|
case "rounds": |
|
|
rounds(interaction.options[0].name, interaction); |
|
|
rounds(interaction.options[0].name, interaction); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "top": |
|
|
|
|
|
showLeaderboard(interaction); |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|