Skip to content

Commit

Permalink
fix: leaderboard functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Faf4a committed Jan 19, 2024
1 parent ba9ea93 commit 6293b7f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/functions/database/globalUserLeaderBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = async (d) => {

if (!type || (type.toLowerCase() !== "asc" && type.toLowerCase() !== "desc")) return d.aoiError.fnError(d, 'custom', {}, `type must be "desc" or "asc"`)

let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === 2, page * list);
let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === 2);
db.sort((a, b) => Number(a.value) - Number(b.value));

if (type === "desc") db = db.reverse();
Expand Down
2 changes: 1 addition & 1 deletion src/functions/database/guildLeaderBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = async (d) => {

if (!type || (type.toLowerCase() !== "asc" && type.toLowerCase() !== "desc")) return d.aoiError.fnError(d, 'custom', {}, `type must be "desc" or "asc"`)

let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === 2, page * list);
let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === 2);

db.sort((a, b) => Number(a.value) - Number(b.value));

Expand Down
2 changes: 1 addition & 1 deletion src/functions/database/rawLeaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = async (d) => {
let y = 0;
let value;
let content = [];
let all = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === type === "user" ? 3 : 2, page * list);
let all = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && data.key.split("_").length === type === "user" ? 3 : 2);

all = all.sort((x, y) => { return Number(y.value) - Number(x.value)});

Expand Down
2 changes: 1 addition & 1 deletion src/functions/database/userLeaderBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = async d => {

if (!order || (order.toLowerCase() !== "asc" && order.toLowerCase() !== "desc")) return d.aoiError.fnError(d, 'custom', {}, `order must be "desc" or "asc"`)

let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && (data.key.split("_").length === 3) && (data.key.split("_")[2] == guildID), page * list);
let db = await d.client.db.all(table, (data) => data.key.startsWith(variable.deleteBrackets()) && (data.key.split("_").length === 3) && (data.key.split("_")[2] == guildID));

db.sort((a, b) => Number(a.value) - Number(b.value));
if (order === "desc") db = db.reverse();
Expand Down

0 comments on commit 6293b7f

Please sign in to comment.