val stats: fix naming scheme for maps, roles and weapons after changing the api endpoint

This commit is contained in:
Ayden Jahola 2024-10-06 16:39:15 +01:00
parent 8a45ac22de
commit d460eff8cc
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742

View file

@ -139,14 +139,22 @@ module.exports = {
.setDescription(`${data.username}'s top weapons stats:`); .setDescription(`${data.username}'s top weapons stats:`);
data.top_weapons.forEach((weapon) => { data.top_weapons.forEach((weapon) => {
weaponsEmbed.addFields({ if (weapon.weapon_name) {
name: weapon.name, weaponsEmbed.addFields({
value: name: weapon.weapon_name,
`Type: ${weapon.weapon_type}\n` + value:
`Kills: ${weapon.kills}\n` + `Type: ${weapon.weapon_type}\n` +
`Accuracy: ${weapon.accuracy.join(", ")}\n`, `Kills: ${weapon.weapon_kills}\n` +
inline: true, `Accuracy: ${
}); Array.isArray(weapon.weapon_accuracy)
? weapon.weapon_accuracy.join(", ")
: "N/A"
}\n`,
inline: true,
});
} else {
console.warn("Weapon name is undefined:", weapon);
}
}); });
embeds.push(weaponsEmbed); embeds.push(weaponsEmbed);
@ -160,11 +168,15 @@ module.exports = {
.setDescription(`${data.username}'s top maps stats:`); .setDescription(`${data.username}'s top maps stats:`);
data.top_maps.forEach((map) => { data.top_maps.forEach((map) => {
mapsEmbed.addFields({ if (map.map_name) {
name: map.name, mapsEmbed.addFields({
value: `Win Percentage: ${map.win_percentage}%\nMatches: ${map.matches}`, name: map.map_name,
inline: true, value: `Win Percentage: ${map.map_win_percentage}%\nMatches: ${map.map_matches}`,
}); inline: true,
});
} else {
console.warn("Map name is undefined:", map);
}
}); });
embeds.push(mapsEmbed); embeds.push(mapsEmbed);
@ -178,18 +190,22 @@ module.exports = {
.setDescription(`${data.username}'s performance by role:`); .setDescription(`${data.username}'s performance by role:`);
data.roles.forEach((role) => { data.roles.forEach((role) => {
rolesEmbed.addFields({ if (role.role_name) {
name: role.name, rolesEmbed.addFields({
value: name: role.role_name,
`Win Rate: ${role.win_rate}%\n` + value:
`KDA: ${role.kda}\n` + `Win Rate: ${role.role_win_rate}%\n` +
`Wins: ${role.wins}\n` + `KDA: ${role.role_kda}\n` +
`Losses: ${role.losses}\n` + `Wins: ${role.role_wins}\n` +
`Kills: ${role.kills}\n` + `Losses: ${role.role_losses}\n` +
`Deaths: ${role.deaths}\n` + `Kills: ${role.role_kills}\n` +
`Assists: ${role.assists}`, `Deaths: ${role.role_deaths}\n` +
inline: true, `Assists: ${role.role_assists}`,
}); inline: true,
});
} else {
console.warn("Role name is undefined:", role);
}
}); });
embeds.push(rolesEmbed); embeds.push(rolesEmbed);