mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 20:49:52 +01:00
feat: actual stats
This commit is contained in:
1 parent
4482b76746
commit
64241febae
2 files changed
+35
-12
No files matched your search
@@ -9,6 +9,7 @@ export default async function (member: GuildMember) {
|
|||||||
await (
|
await (
|
||||||
member.guild.channels.cache.get(discord.verify_channel) as TextChannel
|
member.guild.channels.cache.get(discord.verify_channel) as TextChannel
|
||||||
).send({
|
).send({
|
||||||
|
content: member.toString(),
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(SKILLED_COLOR)
|
.setColor(SKILLED_COLOR)
|
||||||
@@ -22,7 +23,4 @@ export default async function (member: GuildMember) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
await (
|
|
||||||
member.guild.channels.cache.get(discord.verify_channel) as TextChannel
|
|
||||||
).send(member.toString());
|
|
||||||
}
|
}
|
||||||
+34
-9
@@ -5,7 +5,7 @@ import {
|
|||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { SERVERS } from '../constants/servers.js';
|
import { SERVERS } from '../constants/servers.js';
|
||||||
import { PlayerStatistics } from '../types/statistics.js';
|
import { PlayerStatistics } from '../types/statistics.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
@@ -23,15 +23,14 @@ export async function execute(
|
|||||||
| 'career';
|
| 'career';
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
const data = (await (
|
fetch(`https://www.blitzstars.com/api/top/player/${account.account_id}`)
|
||||||
await fetch(
|
.then(async (response) => {
|
||||||
`https://www.blitzstars.com/api/top/player/${account.account_id}`,
|
const data = (await response.json()) as PlayerStatistics;
|
||||||
)
|
|
||||||
).json()) as PlayerStatistics;
|
|
||||||
const stats =
|
const stats =
|
||||||
period === 'career' ? data.statistics : data[`period${period}d`];
|
period === 'career' ? data.statistics : data[`period${period}d`];
|
||||||
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
|
content: 'ass',
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(SKILLED_COLOR)
|
.setColor(SKILLED_COLOR)
|
||||||
@@ -68,7 +67,10 @@ export async function execute(
|
|||||||
'Hits per battle',
|
'Hits per battle',
|
||||||
(stats.all.hits / stats.all.battles).toFixed(2),
|
(stats.all.hits / stats.all.battles).toFixed(2),
|
||||||
],
|
],
|
||||||
['XP per battle', (stats.all.xp / stats.all.battles).toFixed(2)],
|
[
|
||||||
|
'XP per battle',
|
||||||
|
(stats.all.xp / stats.all.battles).toFixed(2),
|
||||||
|
],
|
||||||
[],
|
[],
|
||||||
['Damage ratio', stats.special.damageRatio.toFixed(2)],
|
['Damage ratio', stats.special.damageRatio.toFixed(2)],
|
||||||
['Kills to death ratio', stats.special.kdr.toFixed(2)],
|
['Kills to death ratio', stats.special.kdr.toFixed(2)],
|
||||||
@@ -78,10 +80,33 @@ export async function execute(
|
|||||||
)
|
)
|
||||||
.join(
|
.join(
|
||||||
'\n',
|
'\n',
|
||||||
)}\n\nPowered by [BlitzStars](https://www.blitzstars.com/)`,
|
)}\n\n[View full stats](https://www.blitzstars.com/player/${
|
||||||
),
|
data.region
|
||||||
|
}/${
|
||||||
|
data.nickname
|
||||||
|
}) • [Support BlitzStars](https://www.blitzstars.com/supporters)`,
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: 'Powered by BlitzStars',
|
||||||
|
iconURL:
|
||||||
|
'https://www.blitzstars.com/assets/images/TankyMcPewpew.png',
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`Showing ${data.nickname}'s ${period} stats`);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
interaction.reply({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle('No data to display')
|
||||||
|
.setDescription(`${ign} is not tracked by BlitzStars.`)
|
||||||
|
.setColor(NEGATIVE_COLOR),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user