@@ -29,6 +29,7 @@ const getCoinLeaderboardEmbed = async (
29
29
let rank = 0 ;
30
30
let offset = 0 ;
31
31
let i = 0 ;
32
+ let absoluteCount = 0 ;
32
33
while ( leaderboardArray . length < LEADERBOARD_LIMIT_DISPLAY || position === 0 ) {
33
34
if ( i === LEADERBOARD_LIMIT_FETCH ) {
34
35
offset += LEADERBOARD_LIMIT_FETCH ;
@@ -46,10 +47,15 @@ const getCoinLeaderboardEmbed = async (
46
47
continue ;
47
48
}
48
49
if ( user . bot ) continue ;
49
- if ( previousBalance ! == userCoinEntry . balance ) {
50
+ if ( previousBalance = == userCoinEntry . balance ) {
50
51
previousBalance = userCoinEntry . balance ;
51
- rank = rank + 1 ;
52
+ // rank does not change
53
+ } else {
54
+ previousBalance = userCoinEntry . balance ;
55
+ rank = absoluteCount + 1 ;
52
56
}
57
+ // count how many total users have been processed:
58
+ absoluteCount ++ ;
53
59
if ( userCoinEntry . user_id === userId ) {
54
60
position = rank ;
55
61
}
@@ -64,24 +70,33 @@ const getCoinLeaderboardEmbed = async (
64
70
. join ( '\\_' )
65
71
. split ( '`' )
66
72
. join ( '\\`' ) ;
67
- const userCoinEntryText = `${ rank } . ${ cleanUserTag } - ${
73
+ console . log ( "RANK:" , rank ) ;
74
+ console . log ( "Position:" , position ) ;
75
+ console . log ( "Previous Balance:" , previousBalance ) ;
76
+ console . log ( "offset:" , offset ) ;
77
+ console . log ( "User Coin Entry Balance:" , userCoinEntry . balance ) ;
78
+ const userCoinEntryText = `${ rank } \\. ${ cleanUserTag } - ${
68
79
userCoinEntry . balance
69
80
} ${ getCoinEmoji ( ) } `;
81
+ console . log ( "userCoinEntry is: " , userCoinEntryText ) ;
70
82
leaderboardArray . push ( userCoinEntryText ) ;
71
83
}
72
84
}
73
85
const leaderboardText = leaderboardArray . join ( '\n' ) ;
86
+ console . log ( "leaderboardtext is: " , leaderboardText ) ;
74
87
const leaderboardEmbed = new EmbedBuilder ( )
75
88
. setColor ( DEFAULT_EMBED_COLOUR )
76
89
. setTitle ( 'Codey Coin Leaderboard' )
77
90
. setDescription ( leaderboardText ) ;
91
+
92
+ console . log ( "leaderboard embed is: " , leaderboardEmbed ) ;
78
93
leaderboardEmbed . addFields ( [
79
94
{
80
95
name : 'Your Position' ,
81
96
value : `You are currently **#${ position } ** in the leaderboard with ${ userBalance } ${ getCoinEmoji ( ) } .` ,
82
97
} ,
83
98
] ) ;
84
-
99
+ console . log ( "leaderboard embed is: " , leaderboardEmbed ) ;
85
100
return leaderboardEmbed ;
86
101
} ;
87
102
0 commit comments