mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 00:35:56 +00:00
cs: update the commanad with new api data
This commit is contained in:
parent
d5839f4705
commit
287b64151b
1 changed files with 60 additions and 46 deletions
|
@ -10,26 +10,15 @@ module.exports = {
|
|||
.setName("steam_id")
|
||||
.setDescription("The Steam ID to fetch stats for.")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("stats_type")
|
||||
.setDescription("The type of stats to fetch (premier or competitive).")
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: "Premier", value: "premier" },
|
||||
{ name: "Competitive", value: "competitive" }
|
||||
)
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
const steamId = interaction.options.getString("steam_id");
|
||||
const statsType = interaction.options.getString("stats_type");
|
||||
|
||||
const apiUrl = process.env.TRACKER_API_URL;
|
||||
const apiKey = process.env.TRACKER_API_KEY;
|
||||
|
||||
const url = `https://${apiUrl}/cs2/player/${steamId}/${statsType}`;
|
||||
const url = `https://${apiUrl}/cs2/player/${steamId}`;
|
||||
|
||||
try {
|
||||
await interaction.deferReply();
|
||||
|
@ -44,60 +33,85 @@ module.exports = {
|
|||
|
||||
const statsEmbed = new EmbedBuilder()
|
||||
.setColor("#ff4500")
|
||||
.setTitle(`CS2 Stats for Steam ID: ${data.steam_id} (${statsType})`);
|
||||
|
||||
const rankField = {
|
||||
name:
|
||||
statsType === "competitive"
|
||||
? "🏆 Highest Rank (All maps)"
|
||||
: "🏆 Current Rank",
|
||||
value: data.current_rank,
|
||||
};
|
||||
.setTitle(`CS2 Stats for Steam ID: ${data.steam_id}`);
|
||||
|
||||
const fields = [
|
||||
{ name: "🎮 Steam Name", value: data.player_name },
|
||||
rankField,
|
||||
{ name: "🎮 Steam Name", value: data.player_name || "N/A" },
|
||||
{ name: "⏳ Hours Played", value: `${data.hours_played}h` },
|
||||
{ name: "🎮 Kills", value: `${data.kills}` },
|
||||
{ name: "📈 K/D Ratio", value: `${data.kd_ratio}` },
|
||||
{ name: "🏅 Total Deaths", value: `${data.total_deaths}` },
|
||||
{ name: "🏅 Wins", value: `${data.total_wins}` },
|
||||
{ name: "⚔️ Total Damage Done", value: `${data.total_damage_done}` },
|
||||
{ name: "💰 Total Money Earned", value: `${data.total_money_earned}` },
|
||||
{ name: "🏆 Total MVPs", value: `${data.total_mvps}` },
|
||||
];
|
||||
|
||||
// Adding additional fields dynamically
|
||||
const additionalFields = [
|
||||
{
|
||||
name: "⏳ Hours Played",
|
||||
value: `${data.hours_played}h`,
|
||||
name: "Total Planted Bombs",
|
||||
value: `${data.total_planted_bombs}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "🎮 Matches Played",
|
||||
value: `${data.matches_played}`,
|
||||
name: "Total Defused Bombs",
|
||||
value: `${data.total_defused_bombs}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "🏅 Wins",
|
||||
value: `${data.wins}`,
|
||||
name: "Total Weapons Donated",
|
||||
value: `${data.total_weapons_donated}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "📊 Win Percentage",
|
||||
value: `${data.win_percentage}%`,
|
||||
name: "Total Rounds Played",
|
||||
value: `${data.total_rounds_played}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "⚔️ Kills",
|
||||
value: `${data.kills}`,
|
||||
name: "Total Domination Overkills",
|
||||
value: `${data.total_domination_overkills}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "📈 K/D Ratio",
|
||||
value: `${data.kd_ratio}`,
|
||||
name: "Total Revenges",
|
||||
value: `${data.total_revenges}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "🎯 Headshot Percentage",
|
||||
value: `${data.headshot_percentage}%`,
|
||||
name: "Total Kills (AWP)",
|
||||
value: `${data.total_kills_awp}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "💯 Tracker Score",
|
||||
value: `${data.tracker_score}/1000`,
|
||||
name: "Total Kills (AK47)",
|
||||
value: `${data.total_kills_ak47}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Total Kills (Headshot)",
|
||||
value: `${data.total_kills_headshot}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Total Wins (Pistol Round)",
|
||||
value: `${data.total_wins_pistolround}`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Total Rounds (Dust2)",
|
||||
value: `${data.total_rounds_map_de_dust2}`,
|
||||
inline: true,
|
||||
},
|
||||
];
|
||||
|
||||
// Only add Peak Rank if statsType is not "competitive"
|
||||
if (statsType !== "competitive") {
|
||||
fields.splice(1, 0, {
|
||||
name: "🔝 Peak Rank",
|
||||
value: data.peak_rank || "N/A",
|
||||
});
|
||||
}
|
||||
// Add each additional field if it exists and its value is greater than 0
|
||||
additionalFields.forEach((field) => {
|
||||
if (field.value > 0) {
|
||||
fields.push(field);
|
||||
}
|
||||
});
|
||||
|
||||
statsEmbed.addFields(fields).setTimestamp().setFooter({
|
||||
text: "CS2 Stats API made by Ayden",
|
||||
|
|
Loading…
Reference in a new issue