This commit is contained in:
Christopher Cookman 2023-08-17 18:38:53 -06:00
parent db0c0fdf73
commit a039af4630
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -107,6 +107,15 @@ client.on("interactionCreate", async interaction => {
case "leaderboard": case "leaderboard":
// Get the type option, if its "inverted" then order by points ASC, if its not set then order by points DESC // Get the type option, if its "inverted" then order by points ASC, if its not set then order by points DESC
let type = interaction.options.getString("type") || "DESC"; let type = interaction.options.getString("type") || "DESC";
// Switch type for the header of the embed
switch (type) {
case "DESC":
header = "Leaderboard";
break;
case "ASC":
header = "Inverted Leaderboard";
break;
}
await db.all(`SELECT * FROM points ORDER BY points ${type}`, async (err, rows) => { await db.all(`SELECT * FROM points ORDER BY points ${type}`, async (err, rows) => {
if (err) { if (err) {
console.error(err); console.error(err);
@ -127,7 +136,7 @@ client.on("interactionCreate", async interaction => {
} }
interaction.reply({ interaction.reply({
embeds: [{ embeds: [{
title: "Leaderboard", title: header,
description: leaderboard.join("\n"), description: leaderboard.join("\n"),
color: 0x00ff00 color: 0x00ff00
}] }]