mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 08:45:55 +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")
|
.setName("steam_id")
|
||||||
.setDescription("The Steam ID to fetch stats for.")
|
.setDescription("The Steam ID to fetch stats for.")
|
||||||
.setRequired(true)
|
.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) {
|
async execute(interaction) {
|
||||||
const steamId = interaction.options.getString("steam_id");
|
const steamId = interaction.options.getString("steam_id");
|
||||||
const statsType = interaction.options.getString("stats_type");
|
|
||||||
|
|
||||||
const apiUrl = process.env.TRACKER_API_URL;
|
const apiUrl = process.env.TRACKER_API_URL;
|
||||||
const apiKey = process.env.TRACKER_API_KEY;
|
const apiKey = process.env.TRACKER_API_KEY;
|
||||||
|
|
||||||
const url = `https://${apiUrl}/cs2/player/${steamId}/${statsType}`;
|
const url = `https://${apiUrl}/cs2/player/${steamId}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
@ -44,60 +33,85 @@ module.exports = {
|
||||||
|
|
||||||
const statsEmbed = new EmbedBuilder()
|
const statsEmbed = new EmbedBuilder()
|
||||||
.setColor("#ff4500")
|
.setColor("#ff4500")
|
||||||
.setTitle(`CS2 Stats for Steam ID: ${data.steam_id} (${statsType})`);
|
.setTitle(`CS2 Stats for Steam ID: ${data.steam_id}`);
|
||||||
|
|
||||||
const rankField = {
|
|
||||||
name:
|
|
||||||
statsType === "competitive"
|
|
||||||
? "🏆 Highest Rank (All maps)"
|
|
||||||
: "🏆 Current Rank",
|
|
||||||
value: data.current_rank,
|
|
||||||
};
|
|
||||||
|
|
||||||
const fields = [
|
const fields = [
|
||||||
{ name: "🎮 Steam Name", value: data.player_name },
|
{ name: "🎮 Steam Name", value: data.player_name || "N/A" },
|
||||||
rankField,
|
{ 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",
|
name: "Total Planted Bombs",
|
||||||
value: `${data.hours_played}h`,
|
value: `${data.total_planted_bombs}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🎮 Matches Played",
|
name: "Total Defused Bombs",
|
||||||
value: `${data.matches_played}`,
|
value: `${data.total_defused_bombs}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🏅 Wins",
|
name: "Total Weapons Donated",
|
||||||
value: `${data.wins}`,
|
value: `${data.total_weapons_donated}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "📊 Win Percentage",
|
name: "Total Rounds Played",
|
||||||
value: `${data.win_percentage}%`,
|
value: `${data.total_rounds_played}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "⚔️ Kills",
|
name: "Total Domination Overkills",
|
||||||
value: `${data.kills}`,
|
value: `${data.total_domination_overkills}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "📈 K/D Ratio",
|
name: "Total Revenges",
|
||||||
value: `${data.kd_ratio}`,
|
value: `${data.total_revenges}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "🎯 Headshot Percentage",
|
name: "Total Kills (AWP)",
|
||||||
value: `${data.headshot_percentage}%`,
|
value: `${data.total_kills_awp}`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "💯 Tracker Score",
|
name: "Total Kills (AK47)",
|
||||||
value: `${data.tracker_score}/1000`,
|
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"
|
// Add each additional field if it exists and its value is greater than 0
|
||||||
if (statsType !== "competitive") {
|
additionalFields.forEach((field) => {
|
||||||
fields.splice(1, 0, {
|
if (field.value > 0) {
|
||||||
name: "🔝 Peak Rank",
|
fields.push(field);
|
||||||
value: data.peak_rank || "N/A",
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
statsEmbed.addFields(fields).setTimestamp().setFooter({
|
statsEmbed.addFields(fields).setTimestamp().setFooter({
|
||||||
text: "CS2 Stats API made by Ayden",
|
text: "CS2 Stats API made by Ayden",
|
||||||
|
|
Loading…
Reference in a new issue