@@ -41,7 +41,7 @@ const RankCommand: Command = {
41
41
42
42
const authorizedUserIds = new Set < string > ( [ interaction . user . id ] ) ;
43
43
44
- const embed = await computeRankForExpressionAsync ( guildId , expression , userLocale , authorizedUserIds ) ;
44
+ const embed = await computeRankForExpression ( guildId , expression , userLocale , authorizedUserIds ) ;
45
45
46
46
const displayMyRankTranslation = translations . responses ?. displayMyRank ?. [ userLocale ] ?? "Display my rank" ;
47
47
const displayMyRankButton = new ButtonBuilder ( )
@@ -74,7 +74,7 @@ const RankCommand: Command = {
74
74
75
75
const deferUpdatePromise = i . update ( { content : "" } ) ;
76
76
77
- const editedEmbed = await computeRankForExpressionAsync ( guildId , expression , userLocale , authorizedUserIds ) ;
77
+ const editedEmbed = await computeRankForExpression ( guildId , expression , userLocale , authorizedUserIds ) ;
78
78
await deferUpdatePromise ;
79
79
await i . editReply ( {
80
80
embeds : [ editedEmbed ] ,
@@ -92,7 +92,7 @@ const RankCommand: Command = {
92
92
93
93
export default RankCommand ;
94
94
95
- async function computeRankForExpressionAsync (
95
+ async function computeRankForExpression (
96
96
guildId : string ,
97
97
expression : string ,
98
98
userLocale : string ,
@@ -114,9 +114,12 @@ async function computeRankForExpressionAsync(
114
114
hashMapOfUserId . set ( userIdHash , userId ) ;
115
115
} ) ;
116
116
117
+ // Show top 10 AND already displayed users
117
118
let embedDescription = rankResult
118
- . map ( ( result , index ) => {
119
+ . filter ( ( result ) => result . rank <= 10 || displayedUsersIds . has ( result . author_id ) )
120
+ . map ( ( result ) => {
119
121
let userName ;
122
+ // 128 means hashed user ID
120
123
if ( result . author_id . length === 128 ) {
121
124
const realUserId = hashMapOfUserId . get ( result . author_id ) ;
122
125
if ( realUserId ) {
@@ -128,7 +131,7 @@ async function computeRankForExpressionAsync(
128
131
userName = userMention ( result . author_id ) ;
129
132
}
130
133
131
- const userRank = index + 1 ;
134
+ const userRank = result . rank ;
132
135
const userCount = result . count ;
133
136
const userPercentage = ( ( userCount / totalCount ) * 100 ) . toFixed ( 2 ) ;
134
137
0 commit comments