Skip to content

Commit

Permalink
fix: leaderboard points
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetfulskybro committed Sep 22, 2024
1 parent 72bf20f commit 3c92230
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 36 deletions.
28 changes: 16 additions & 12 deletions src/buttons/pagination/paginateLast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,22 @@ const button: Button = {
);
} else {
data = await Promise.all(
guildDb.gameScores.sort((a: any, b: any) => b.higherlower - a.higherlower).slice((paginate.pages.length - 1) * 10).map(async (u: any) => {
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
guildDb.gameScores
.filter((u: any) => u.higherlower >= 1)
.sort((a: any, b: any) => b.higherlower - a.higherlower)
.slice((paginate.pages.length - 1) * 10)
.map(async (u: any) => {
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
);
}

Expand Down
29 changes: 17 additions & 12 deletions src/buttons/pagination/paginateNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,23 @@ const button: Button = {
);
} else {
data = await Promise.all(
guildDb.gameScores.sort((a: any, b: any) => b.higherlower - a.higherlower).slice(paginate.page * 10).map(async (u: any) => { // , paginate.page * 10 + 10
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
guildDb.gameScores
.filter((u: any) => u.higherlower >= 1)
.sort((a: any, b: any) => b.higherlower - a.higherlower)
.slice(paginate.page * 10)
.map(async (u: any) => {
// , paginate.page * 10 + 10
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
);
}

Expand Down
27 changes: 15 additions & 12 deletions src/buttons/pagination/paginatePrev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,21 @@ const button: Button = {
);
} else {
data = await Promise.all(
guildDb.gameScores.map(async (u: any) => {
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
guildDb.gameScores
.filter((u: any) => u.higherlower >= 1)
.sort((a: any, b: any) => b.higherlower - a.higherlower)
.map(async (u: any) => {
const user = await client.database.getUser(u.userID, true);
return user?.votePrivacy
? {
user: "Anonymous",
score: u.higherlower,
}
: {
user: u.userID,
score: u.higherlower,
};
}),
);
}

Expand Down
1 change: 1 addition & 0 deletions src/commands/game/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const command: ChatInputCommand = {
}
data = await Promise.all(
guildDb.gameScores
.filter((u: any) => u.higherlower >= 1)
.sort((a: any, b: any) => b.higherlower - a.higherlower)
.map(async (u: any) => {
const user = await client.database.getUser(u.userID, true);
Expand Down

0 comments on commit 3c92230

Please sign in to comment.