@@ -427,7 +427,7 @@ module.exports = {
427427 success : true
428428 }
429429 } ) ;
430-
430+
431431 // Processar ranking manualmente
432432 const userStats = { } ;
433433 modifications . forEach ( mod => {
@@ -439,28 +439,41 @@ module.exports = {
439439 userStats [ mod . userId ] . success_xp += 100 ;
440440 }
441441 } ) ;
442-
442+
443443 // Converter para array e ordenar
444444 const ranking = Object . entries ( userStats )
445445 . map ( ( [ userId , stats ] ) => ( {
446446 userId,
447- username : 'Usuário' ,
448447 modifications : stats . modifications ,
449448 success_xp : stats . success_xp
450449 } ) )
451450 . sort ( ( a , b ) => b . modifications - a . modifications || b . success_xp - a . success_xp )
452451 . slice ( 0 , 10 ) ;
453-
452+
454453 if ( ranking . length === 0 ) {
455454 return message . reply ( '📊 Ainda não há ranking disponível. Seja o primeiro a participar!' ) ;
456455 }
457-
458- const rankingText = ranking . map ( ( user , index ) => {
459- const medals = [ '🥇' , '🥈' , '🥉' ] ;
460- const medal = medals [ index ] || '🏅' ;
461- return `${ medal } **${ user . username || 'Usuário' } ** - ${ user . modifications } modificações` ;
462- } ) . join ( '\n' ) ;
463-
456+
457+ // Buscar nomes dos usuários via Discord API
458+ const fetchUsername = async ( userId ) => {
459+ try {
460+ const user = await message . client . users . fetch ( userId ) ;
461+ return user . username ;
462+ } catch {
463+ return 'Usuário' ;
464+ }
465+ } ;
466+
467+ // Montar rankingText com usernames reais
468+ const rankingText = await Promise . all (
469+ ranking . map ( async ( user , index ) => {
470+ const medals = [ '🥇' , '🥈' , '🥉' ] ;
471+ const medal = medals [ index ] || '🏅' ;
472+ const username = await fetchUsername ( user . userId ) ;
473+ return `${ medal } **${ username } ** - ${ user . modifications } modificações` ;
474+ } )
475+ ) . then ( lines => lines . join ( '\n' ) ) ;
476+
464477 const embed = {
465478 color : 0xffd93d ,
466479 title : '🏆 Ranking Bug Hunt' ,
@@ -469,7 +482,7 @@ module.exports = {
469482 text : 'Baseado no número total de participações'
470483 }
471484 } ;
472-
485+
473486 return message . reply ( { embeds : [ embed ] } ) ;
474487 } ,
475488
0 commit comments