File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -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,7 +70,8 @@ const getCoinLeaderboardEmbed = async (
64
70
. join ( '\\_' )
65
71
. split ( '`' )
66
72
. join ( '\\`' ) ;
67
- const userCoinEntryText = `${ rank } . ${ cleanUserTag } - ${
73
+ // added a "\\" below in ${rank}\\. ${cleanUserTag} so that Markdown does not automatically increment by 1 each time
74
+ const userCoinEntryText = `${ rank } \\. ${ cleanUserTag } - ${
68
75
userCoinEntry . balance
69
76
} ${ getCoinEmoji ( ) } `;
70
77
leaderboardArray . push ( userCoinEntryText ) ;
@@ -81,7 +88,6 @@ const getCoinLeaderboardEmbed = async (
81
88
value : `You are currently **#${ position } ** in the leaderboard with ${ userBalance } ${ getCoinEmoji ( ) } .` ,
82
89
} ,
83
90
] ) ;
84
-
85
91
return leaderboardEmbed ;
86
92
} ;
87
93
You can’t perform that action at this time.
0 commit comments