val stats: format accuracy with head, body and legs

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

View file

@ -119,7 +119,12 @@ module.exports = {
name: "🎯 Headshot Percentage", name: "🎯 Headshot Percentage",
value: `${data.headshot_percentage}%`, value: `${data.headshot_percentage}%`,
} }
); )
.setTimestamp()
.setFooter({
text: "Valorant Stats API made by Ayden",
iconURL: interaction.guild.iconURL(),
});
// Add the Tracker Score field only if statsType is "current" // Add the Tracker Score field only if statsType is "current"
if (statsType === "current") { if (statsType === "current") {
@ -136,20 +141,26 @@ module.exports = {
const weaponsEmbed = new EmbedBuilder() const weaponsEmbed = new EmbedBuilder()
.setColor("#0099ff") .setColor("#0099ff")
.setTitle(`${data.username}'s Top Weapons`) .setTitle(`${data.username}'s Top Weapons`)
.setDescription(`${data.username}'s top weapons stats:`); .setDescription(`${data.username}'s top weapons stats:`)
.setTimestamp()
.setFooter({
text: "Valorant Stats API made by Ayden",
iconURL: interaction.guild.iconURL(),
});
data.top_weapons.forEach((weapon) => { data.top_weapons.forEach((weapon) => {
if (weapon.weapon_name) { if (weapon.weapon_name) {
const accuracy = Array.isArray(weapon.weapon_accuracy)
? weapon.weapon_accuracy
: ["N/A", "N/A", "N/A"];
const formattedAccuracy = `Head: ${accuracy[0]}\nBody: ${accuracy[1]}\nLegs: ${accuracy[2]}`;
weaponsEmbed.addFields({ weaponsEmbed.addFields({
name: weapon.weapon_name, name: weapon.weapon_name,
value: value:
`Type: ${weapon.weapon_type}\n` + `Type: ${weapon.weapon_type}\n` +
`Kills: ${weapon.weapon_kills}\n` + `Kills: ${weapon.weapon_kills}\n` +
`Accuracy: ${ `**Accuracy**: \n${formattedAccuracy}\n`,
Array.isArray(weapon.weapon_accuracy)
? weapon.weapon_accuracy.join(", ")
: "N/A"
}\n`,
inline: true, inline: true,
}); });
} else { } else {
@ -165,7 +176,12 @@ module.exports = {
const mapsEmbed = new EmbedBuilder() const mapsEmbed = new EmbedBuilder()
.setColor("#0099ff") .setColor("#0099ff")
.setTitle(`${data.username}'s Top Maps`) .setTitle(`${data.username}'s Top Maps`)
.setDescription(`${data.username}'s top maps stats:`); .setDescription(`${data.username}'s top maps stats:`)
.setTimestamp()
.setFooter({
text: "Valorant Stats API made by Ayden",
iconURL: interaction.guild.iconURL(),
});
data.top_maps.forEach((map) => { data.top_maps.forEach((map) => {
if (map.map_name) { if (map.map_name) {
@ -187,7 +203,12 @@ module.exports = {
const rolesEmbed = new EmbedBuilder() const rolesEmbed = new EmbedBuilder()
.setColor("#0099ff") .setColor("#0099ff")
.setTitle(`${data.username}'s Roles`) .setTitle(`${data.username}'s Roles`)
.setDescription(`${data.username}'s performance by role:`); .setDescription(`${data.username}'s performance by role:`)
.setTimestamp()
.setFooter({
text: "Valorant Stats API made by Ayden",
iconURL: interaction.guild.iconURL(),
});
data.roles.forEach((role) => { data.roles.forEach((role) => {
if (role.role_name) { if (role.role_name) {
@ -211,11 +232,6 @@ module.exports = {
embeds.push(rolesEmbed); embeds.push(rolesEmbed);
} }
statsEmbed.setTimestamp().setFooter({
text: "Valorant Stats API made by Ayden",
iconURL: interaction.guild.iconURL(),
});
return interaction.editReply({ embeds }); return interaction.editReply({ embeds });
} catch (error) { } catch (error) {
console.error("Error fetching player stats:", error); console.error("Error fetching player stats:", error);