mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 00:35:56 +00:00
val stats: make weapn, maps and roles optional
This commit is contained in:
parent
c9a411779f
commit
455ae98287
1 changed files with 90 additions and 54 deletions
|
@ -22,10 +22,31 @@ module.exports = {
|
||||||
{ name: "All Acts Stats", value: "all" }
|
{ name: "All Acts Stats", value: "all" }
|
||||||
)
|
)
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addBooleanOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("include_weapons")
|
||||||
|
.setDescription("Include top weapons stats?")
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addBooleanOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("include_maps")
|
||||||
|
.setDescription("Include top maps stats?")
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addBooleanOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("include_roles")
|
||||||
|
.setDescription("Include roles stats?")
|
||||||
|
.setRequired(false)
|
||||||
),
|
),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const username = interaction.options.getString("username");
|
const username = interaction.options.getString("username");
|
||||||
const statsType = interaction.options.getString("stats_type");
|
const statsType = interaction.options.getString("stats_type");
|
||||||
|
const includeWeapons = interaction.options.getBoolean("include_weapons");
|
||||||
|
const includeMaps = interaction.options.getBoolean("include_maps");
|
||||||
|
const includeRoles = interaction.options.getBoolean("include_roles");
|
||||||
|
|
||||||
// Convert the username by replacing "#" with "%23"
|
// Convert the username by replacing "#" with "%23"
|
||||||
const formattedUsername = username.replace("#", "%23");
|
const formattedUsername = username.replace("#", "%23");
|
||||||
|
@ -55,37 +76,37 @@ module.exports = {
|
||||||
.addFields(
|
.addFields(
|
||||||
{
|
{
|
||||||
name: "🏆 Current Rank",
|
name: "🏆 Current Rank",
|
||||||
value: data.current_rank || "N/A",
|
value: data.current_rank,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🔝 Peak Rank",
|
name: "🔝 Peak Rank",
|
||||||
value: `${data.peak_rank || "N/A"}`,
|
value: `${data.peak_rank} (${data.peak_rank_episode})`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "⏳ Hours Played",
|
name: "⏳ Hours Played",
|
||||||
value: `${data.playtime_hours || 0}h`,
|
value: `${data.playtime_hours}h`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🎮 Matches Played",
|
name: "🎮 Matches Played",
|
||||||
value: `${data.matches_played || 0}`,
|
value: `${data.matches_played}`,
|
||||||
},
|
},
|
||||||
{ name: "🏅 Wins", value: `${data.wins || 0}` },
|
{ name: "🏅 Wins", value: `${data.wins}` },
|
||||||
{
|
{
|
||||||
name: "📊 Win Percentage",
|
name: "📊 Win Percentage",
|
||||||
value: `${data.win_percentage || 0}%`,
|
value: `${data.win_percentage}%`,
|
||||||
},
|
},
|
||||||
{ name: "⚔️ Kills", value: `${data.kills || 0}` },
|
{ name: "⚔️ Kills", value: `${data.kills}` },
|
||||||
{
|
{
|
||||||
name: "📈 K/D Ratio",
|
name: "📈 K/D Ratio",
|
||||||
value: `${data.kd_ratio || 0}`,
|
value: `${data.kd_ratio}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "📊 ACS",
|
name: "📊 ACS",
|
||||||
value: `${data.acs || 0}`,
|
value: `${data.acs}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🎯 Headshot Percentage",
|
name: "🎯 Headshot Percentage",
|
||||||
value: `${data.headshot_percentage || 0}%`,
|
value: `${data.headshot_percentage}%`,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -93,67 +114,82 @@ module.exports = {
|
||||||
if (statsType === "current") {
|
if (statsType === "current") {
|
||||||
statsEmbed.addFields({
|
statsEmbed.addFields({
|
||||||
name: "💯 Tracker Score",
|
name: "💯 Tracker Score",
|
||||||
value: `${data.tracker_score || "N/A"}/1000`,
|
value: `${data.tracker_score}/1000`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const weaponsEmbed = new EmbedBuilder()
|
const embeds = [statsEmbed];
|
||||||
.setColor("#0099ff")
|
|
||||||
.setTitle(`${data.username}'s Top Weapons`)
|
|
||||||
.setDescription(`${data.username}'s top weapons stats:`);
|
|
||||||
|
|
||||||
data.top_weapons.forEach((weapon) => {
|
// Optional weapons embed
|
||||||
weaponsEmbed.addFields({
|
if (includeWeapons) {
|
||||||
name: weapon.name,
|
const weaponsEmbed = new EmbedBuilder()
|
||||||
value:
|
.setColor("#0099ff")
|
||||||
`Type: ${weapon.weapon_type}\n` +
|
.setTitle(`${data.username}'s Top Weapons`)
|
||||||
`Kills: ${weapon.kills}\n` +
|
.setDescription(`${data.username}'s top weapons stats:`);
|
||||||
`Accuracy: ${weapon.accuracy.join(", ")}\n`,
|
|
||||||
inline: true,
|
data.top_weapons.forEach((weapon) => {
|
||||||
|
weaponsEmbed.addFields({
|
||||||
|
name: weapon.name,
|
||||||
|
value:
|
||||||
|
`Type: ${weapon.weapon_type}\n` +
|
||||||
|
`Kills: ${weapon.kills}\n` +
|
||||||
|
`Accuracy: ${weapon.accuracy.join(", ")}\n`,
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const mapsEmbed = new EmbedBuilder()
|
embeds.push(weaponsEmbed);
|
||||||
.setColor("#0099ff")
|
}
|
||||||
.setTitle(`${data.username}'s Top Maps`)
|
|
||||||
.setDescription(`${data.username}'s top maps stats:`);
|
|
||||||
|
|
||||||
data.top_maps.forEach((map) => {
|
// Optional maps embed
|
||||||
mapsEmbed.addFields({
|
if (includeMaps) {
|
||||||
name: map.name,
|
const mapsEmbed = new EmbedBuilder()
|
||||||
value: `Win Percentage: ${map.win_percentage}%\nMatches: ${map.matches}`,
|
.setColor("#0099ff")
|
||||||
inline: true,
|
.setTitle(`${data.username}'s Top Maps`)
|
||||||
|
.setDescription(`${data.username}'s top maps stats:`);
|
||||||
|
|
||||||
|
data.top_maps.forEach((map) => {
|
||||||
|
mapsEmbed.addFields({
|
||||||
|
name: map.name,
|
||||||
|
value: `Win Percentage: ${map.win_percentage}%\nMatches: ${map.matches}`,
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const rolesEmbed = new EmbedBuilder()
|
embeds.push(mapsEmbed);
|
||||||
.setColor("#0099ff")
|
}
|
||||||
.setTitle(`${data.username}'s Roles`)
|
|
||||||
.setDescription(`${data.username}'s performance by role:`);
|
|
||||||
|
|
||||||
data.roles.forEach((role) => {
|
// Optional roles embed
|
||||||
rolesEmbed.addFields({
|
if (includeRoles) {
|
||||||
name: role.name,
|
const rolesEmbed = new EmbedBuilder()
|
||||||
value:
|
.setColor("#0099ff")
|
||||||
`Win Rate: ${role.win_rate}%\n` +
|
.setTitle(`${data.username}'s Roles`)
|
||||||
`KDA: ${role.kda}\n` +
|
.setDescription(`${data.username}'s performance by role:`);
|
||||||
`Wins: ${role.wins}\n` +
|
|
||||||
`Losses: ${role.losses}\n` +
|
data.roles.forEach((role) => {
|
||||||
`Kills: ${role.kills}\n` +
|
rolesEmbed.addFields({
|
||||||
`Deaths: ${role.deaths}\n` +
|
name: role.name,
|
||||||
`Assists: ${role.assists}`,
|
value:
|
||||||
inline: true,
|
`Win Rate: ${role.win_rate}%\n` +
|
||||||
|
`KDA: ${role.kda}\n` +
|
||||||
|
`Wins: ${role.wins}\n` +
|
||||||
|
`Losses: ${role.losses}\n` +
|
||||||
|
`Kills: ${role.kills}\n` +
|
||||||
|
`Deaths: ${role.deaths}\n` +
|
||||||
|
`Assists: ${role.assists}`,
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
embeds.push(rolesEmbed);
|
||||||
|
}
|
||||||
|
|
||||||
statsEmbed.setTimestamp().setFooter({
|
statsEmbed.setTimestamp().setFooter({
|
||||||
text: "Valorant Stats API made by Ayden",
|
text: "Valorant Stats API made by Ayden",
|
||||||
iconURL: interaction.guild.iconURL(),
|
iconURL: interaction.guild.iconURL(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction.editReply({
|
return interaction.editReply({ embeds });
|
||||||
embeds: [statsEmbed, weaponsEmbed, mapsEmbed, rolesEmbed],
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching player stats:", error);
|
console.error("Error fetching player stats:", error);
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
|
|
Loading…
Reference in a new issue