@@ -273,10 +273,46 @@ module.exports = {
273273 const currentCode = await this . getCurrentCode ( currentChallenge , prisma ) ;
274274 const codeLines = currentCode . split ( '\n' ) ;
275275
276- // Numerar as linhas para facilitar referência
277- const numberedCode = codeLines . map ( ( line , index ) =>
278- `${ ( index + 1 ) . toString ( ) . padStart ( 2 , ' ' ) } | ${ line } `
279- ) . join ( '\n' ) ;
276+ // Buscar modificações para identificar quais linhas foram alteradas
277+ const modifications = await prisma . bugHuntModification . findMany ( {
278+ where : {
279+ challengeId : currentChallenge . id ,
280+ guildId : message . guild . id
281+ } ,
282+ orderBy : [
283+ { line : 'asc' } ,
284+ { createdAt : 'desc' }
285+ ]
286+ } ) ;
287+
288+ // Mapear status das linhas modificadas
289+ const lineStatus = new Map ( ) ;
290+ modifications . forEach ( mod => {
291+ if ( ! lineStatus . has ( mod . line ) ||
292+ lineStatus . get ( mod . line ) . createdAt < mod . createdAt ) {
293+ lineStatus . set ( mod . line , {
294+ success : mod . success ,
295+ createdAt : mod . createdAt ,
296+ userId : mod . userId
297+ } ) ;
298+ }
299+ } ) ;
300+
301+ // Numerar as linhas com indicadores de status
302+ const numberedCode = codeLines . map ( ( line , index ) => {
303+ const lineNum = index + 1 ;
304+ const status = lineStatus . get ( lineNum ) ;
305+ let prefix = `${ lineNum . toString ( ) . padStart ( 2 , ' ' ) } | ` ;
306+
307+ // Adicionar indicadores visuais
308+ if ( status ) {
309+ prefix = status . success
310+ ? `${ lineNum . toString ( ) . padStart ( 2 , ' ' ) } ✅ `
311+ : `${ lineNum . toString ( ) . padStart ( 2 , ' ' ) } ❌ ` ;
312+ }
313+
314+ return prefix + line ;
315+ } ) . join ( '\n' ) ;
280316
281317 // Buscar estatísticas de modificações
282318 const totalModifications = await prisma . bugHuntModification . count ( {
@@ -365,6 +401,11 @@ module.exports = {
365401 name : '🎮 Como Participar' ,
366402 value : '`l~bughunt fix <linha> <código>` - Corrigir linha\n`l~bughunt test` - Testar código atual\n`l~bughunt rank` - Ver ranking' ,
367403 inline : false
404+ } ,
405+ {
406+ name : '📋 Legenda' ,
407+ value : '✅ = Modificação aprovada\n❌ = Modificação rejeitada\n| = Linha original' ,
408+ inline : false
368409 }
369410 ] ,
370411 footer : {
@@ -660,19 +701,19 @@ module.exports = {
660701 return message . reply ( '❌ Nenhum desafio ativo no momento!' ) ;
661702 }
662703
663- // Obter código atual com modificações aplicadas
664- const currentCode = await this . getCurrentCode ( currentChallenge , prisma ) ;
704+ // Obter código atual com APENAS modificações aprovadas para execução
705+ const executableCode = await this . getCurrentCodeForExecution ( currentChallenge , prisma ) ;
665706
666707 // Executar teste
667708 const testResult = await this . executeChallenge ( {
668709 ...currentChallenge ,
669- buggyCode : currentCode
710+ buggyCode : executableCode
670711 } , prisma ) ;
671712
672713 const embed = {
673714 color : testResult . success ? 0x00ff00 : 0xff6b6b ,
674715 title : testResult . success ? '✅ Teste Aprovado!' : '❌ Teste Falhado' ,
675- description : `Resultado do teste do código atual:` ,
716+ description : `Resultado do teste do código atual (apenas modificações aprovadas) :` ,
676717 fields : [
677718 {
678719 name : '📊 Resultado' ,
@@ -999,7 +1040,44 @@ module.exports = {
9991040 // Começar com o código buggy original
10001041 let codeLines = challenge . buggyCode . split ( '\n' ) ;
10011042
1002- // Buscar todas as modificações aprovadas, ordenadas por linha
1043+ // Buscar todas as modificações (aprovadas E rejeitadas), ordenadas por linha
1044+ const modifications = await prisma . bugHuntModification . findMany ( {
1045+ where : {
1046+ challengeId : challenge . id
1047+ // Removido filtro success: true para mostrar TODAS as modificações
1048+ } ,
1049+ orderBy : [
1050+ { line : 'asc' } , // Primeiro por linha
1051+ { createdAt : 'desc' } // Depois pela mais recente se houver múltiplas na mesma linha
1052+ ]
1053+ } ) ;
1054+
1055+ // Aplicar modificações por linha (sempre a mais recente)
1056+ const lineModifications = new Map ( ) ;
1057+
1058+ // Mapear a modificação mais recente para cada linha
1059+ modifications . forEach ( mod => {
1060+ if ( ! lineModifications . has ( mod . line ) ||
1061+ lineModifications . get ( mod . line ) . createdAt < mod . createdAt ) {
1062+ lineModifications . set ( mod . line , mod ) ;
1063+ }
1064+ } ) ;
1065+
1066+ // Aplicar as modificações nas linhas correspondentes
1067+ lineModifications . forEach ( ( mod , lineNumber ) => {
1068+ if ( lineNumber >= 1 && lineNumber <= codeLines . length ) {
1069+ codeLines [ lineNumber - 1 ] = mod . code ; // Arrays são 0-indexados
1070+ }
1071+ } ) ;
1072+
1073+ return codeLines . join ( '\n' ) ;
1074+ } ,
1075+
1076+ async getCurrentCodeForExecution ( challenge , prisma ) {
1077+ // Começar com o código buggy original
1078+ let codeLines = challenge . buggyCode . split ( '\n' ) ;
1079+
1080+ // Buscar APENAS modificações aprovadas para execução
10031081 const modifications = await prisma . bugHuntModification . findMany ( {
10041082 where : {
10051083 challengeId : challenge . id ,
0 commit comments