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) => {
if (weapon.weapon_name) {
weaponsEmbed.addFields({ weaponsEmbed.addFields({
name: weapon.name, name: weapon.weapon_name,
value: value:
`Type: ${weapon.weapon_type}\n` + `Type: ${weapon.weapon_type}\n` +
`Kills: ${weapon.kills}\n` + `Kills: ${weapon.weapon_kills}\n` +
`Accuracy: ${weapon.accuracy.join(", ")}\n`, `Accuracy: ${
Array.isArray(weapon.weapon_accuracy)
? weapon.weapon_accuracy.join(", ")
: "N/A"
}\n`,
inline: true, 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) => {
if (map.map_name) {
mapsEmbed.addFields({ mapsEmbed.addFields({
name: map.name, name: map.map_name,
value: `Win Percentage: ${map.win_percentage}%\nMatches: ${map.matches}`, value: `Win Percentage: ${map.map_win_percentage}%\nMatches: ${map.map_matches}`,
inline: true, 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) => {
if (role.role_name) {
rolesEmbed.addFields({ rolesEmbed.addFields({
name: role.name, name: role.role_name,
value: value:
`Win Rate: ${role.win_rate}%\n` + `Win Rate: ${role.role_win_rate}%\n` +
`KDA: ${role.kda}\n` + `KDA: ${role.role_kda}\n` +
`Wins: ${role.wins}\n` + `Wins: ${role.role_wins}\n` +
`Losses: ${role.losses}\n` + `Losses: ${role.role_losses}\n` +
`Kills: ${role.kills}\n` + `Kills: ${role.role_kills}\n` +
`Deaths: ${role.deaths}\n` + `Deaths: ${role.role_deaths}\n` +
`Assists: ${role.assists}`, `Assists: ${role.role_assists}`,
inline: true, inline: true,
}); });
} else {
console.warn("Role name is undefined:", role);
}
}); });
embeds.push(rolesEmbed); embeds.push(rolesEmbed);