mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: /stats to getTankStatsOverTime
This commit is contained in:
1 parent
513bea6f09
commit
fcf7d99012
2 files changed
+48
-104
No files matched your search
@@ -1,25 +0,0 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { PlayerPeriodicStatsCollection } from '../../types/statistics.js';
|
||||
import { notTrackedByBlitzStars } from '../interaction/notTrackedByBlitzStars.js';
|
||||
|
||||
export default async function getBlitzStarsAccount(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
accountId: number,
|
||||
) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://www.blitzstars.com/api/top/player/${accountId}`,
|
||||
);
|
||||
const parsed = (await response.json()) as PlayerPeriodicStatsCollection;
|
||||
|
||||
if (parsed.statistics) {
|
||||
return parsed;
|
||||
} else throw new Error('No data to display');
|
||||
} catch (error) {
|
||||
await interaction.editReply({
|
||||
embeds: [notTrackedByBlitzStars],
|
||||
});
|
||||
|
||||
throw new Error(`${accountId} not tracked by BlitzStars.`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user