Skip to content

Commit

Permalink
Fix history command to pull up latest game instead of first
Browse files Browse the repository at this point in the history
  • Loading branch information
Darklit committed Nov 14, 2024
1 parent b401cd7 commit 2f173d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions commands/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = {
interaction.reply({content:"No previous match history",ephemeral:true}).catch(console.error);
return;
}
var historyId = data.history[0];
var historyId = data.history[data.history.length-1];

history.findOne({"_id":historyId}).then((hist) => {
if (hist == null){
Expand All @@ -96,25 +96,25 @@ module.exports = {
teamANames.push(k);
if(k == data.user.dname){
playerObj = hist['0'][`${k}`];
break;
}
}
for(var k of Object.keys(hist['1'])){
teamBNames.push(k);
if(k == data.user.dname){
playerObj = hist['1'][`${k}`];
break;
}
}
var message = '';
for(var i in teamANames){
message+=teamANames[i];
if(i+1 != teamANames.length) message+=", ";
if(parseInt(i)+1 != teamANames.length) message+=", ";
}
message+=" v. ";
for(var i in teamBNames){
message+=teamBNames[i];
if(i+1 != teamBNames.length) message+=", ";
if(parseInt(i)+1 != teamBNames.length){
message+=", ";
}
}
message+="\n\n**PERSONAL STATS:** \n\n";
for(var c of choices){
Expand Down

0 comments on commit 2f173d4

Please sign in to comment.