|
@ -14,7 +14,7 @@ export async function execute(interaction) { |
|
|
userScore |
|
|
userScore |
|
|
.find({}) |
|
|
.find({}) |
|
|
.sort({ score: -1 }) // Sort by descending order
|
|
|
.sort({ score: -1 }) // Sort by descending order
|
|
|
.exec((err, obj) => { |
|
|
.exec(async (err, obj) => { |
|
|
if (err) { |
|
|
if (err) { |
|
|
log({ logger: 'top', content: `Getting top players failed: ${err}`, level: 'error' }); |
|
|
log({ logger: 'top', content: `Getting top players failed: ${err}`, level: 'error' }); |
|
|
console.log(err); |
|
|
console.log(err); |
|
@ -42,11 +42,10 @@ export async function execute(interaction) { |
|
|
embeds.push(leaderboardEmbed); |
|
|
embeds.push(leaderboardEmbed); |
|
|
|
|
|
|
|
|
let sMessageContent = ''; |
|
|
let sMessageContent = ''; |
|
|
const members = interaction.guild.members.cache; |
|
|
const members = await interaction.guild.members.fetch(); |
|
|
|
|
|
|
|
|
const serverLeaderBoardArray = obj.filter(o => members.some(m => m.user.id === o.authorID)); |
|
|
const serverLeaderBoardArray = await obj.filter(o => members.some(m => m.user.id === o.authorID)); |
|
|
console.log(serverLeaderBoardArray[0]); |
|
|
if (serverLeaderBoardArray.length > 10) { |
|
|
if (serverLeaderBoardArray.length < 10) { |
|
|
|
|
|
for (let i = 0; i < 10; i++) { |
|
|
for (let i = 0; i < 10; i++) { |
|
|
sMessageContent += `${i + 1}: <@${serverLeaderBoardArray[i].authorID}>: ${serverLeaderBoardArray[i].score}\n`; |
|
|
sMessageContent += `${i + 1}: <@${serverLeaderBoardArray[i].authorID}>: ${serverLeaderBoardArray[i].score}\n`; |
|
|
} |
|
|
} |
|
|