ScionSpy / G-C-A_V2

MIT License
1 stars 0 forks source link

BUG - ClanBattles - WLR duplicates #5

Open ScionSpy opened 1 month ago

ScionSpy commented 1 month ago

Describe the bug

When executing the GCA.ClanBattles.WLR sub Event the data caches. Once you execute it consecutive times following a restart, the data duplicates.

To Reproduce

Steps to reproduce the behavior:

  1. execute command: ...evald bot.emit('clanBattles', bot, 'wlr');
  2. repeat step 1.

Expected behavior

The Event to remain the same data as first step, unless additional battles have been played. NOT for the data to cache and duplicate.

Screenshots

If applicable, add screenshots to help explain your problem. image

schoterson commented 1 week ago

this may be completely incorrect.. but it seems that your results is global and you don't reset it at the end of the process. so when you call this script its adding maps twice to the results which in turn is causing the battleResults to loop twice thus doubling the stats.

https://github.com/ScionSpy/G-C-A_V2/blob/af0a9e697e73987e22894581e27b1660bfaba113/Src/Discord/Events/GCA/clanBattles.js#L65

so after this line here https://github.com/ScionSpy/G-C-A_V2/blob/af0a9e697e73987e22894581e27b1660bfaba113/Src/Discord/Events/GCA/clanBattles.js#L233

maybe you do results[2].list = []?