mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
feat: /tankstats
This commit is contained in:
1 parent
d62ca080e9
commit
5b918d6e3e
16 files changed
+317
-33
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
ApplicationCommandOptionChoiceData,
|
||||
AutocompleteInteraction,
|
||||
CacheType,
|
||||
} from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import { tanks } from '../../utilities/tankopedia.js';
|
||||
|
||||
export default async function tanksAutocomplete(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
|
||||
await interaction.respond(
|
||||
focusedValue
|
||||
? go(focusedValue, tanks, { keys: ['name'], limit: 10 }).map(
|
||||
(item) =>
|
||||
({
|
||||
name: item.obj.name
|
||||
? item.obj.name
|
||||
: `Unknown Tank ${item.obj.tank_id}`,
|
||||
value: `${item.obj.tank_id}`,
|
||||
} satisfies ApplicationCommandOptionChoiceData<string>),
|
||||
)
|
||||
: [],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
export interface Period {
|
||||
statsId: number;
|
||||
account_id: number;
|
||||
tank_id: number;
|
||||
recordDate: string;
|
||||
last_battle_time: number;
|
||||
fromDate: string;
|
||||
prior_battle_time: number;
|
||||
battles: number;
|
||||
wins: number;
|
||||
losses: number;
|
||||
spotted: number;
|
||||
shots: number;
|
||||
hits: number;
|
||||
xp: number;
|
||||
battle_life_time: number;
|
||||
frags: number;
|
||||
max_frags: number;
|
||||
damage_dealt: number;
|
||||
damage_received: number;
|
||||
survived_battles: number;
|
||||
win_and_survived: number;
|
||||
capture_points: number;
|
||||
dropped_capture_points: number;
|
||||
killStealerValue: number;
|
||||
isRating: boolean;
|
||||
wn8: number;
|
||||
region: string;
|
||||
}
|
||||
|
||||
export default async function getPeriodicStats(id: number, period: number) {
|
||||
const response = await fetch(
|
||||
`https://blitztankstats.com/api/Stats/period/${id}/${period}`,
|
||||
);
|
||||
return (await response.json()) as Period[];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import errorEmbed from './errorEmbed.js';
|
||||
|
||||
export const badNicknameFormat = errorEmbed(
|
||||
'Bad nickname format',
|
||||
'I expected your nickname to be... \n\n```\nIN_GAME_NAME (SERVER) [CLAN_TAG]\n```\nUse the `/verify` command to setup your nickname correctly or manually provide me with your in-game name and server in the command.',
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function errorEmbed(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(title)
|
||||
.setDescription(description);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import errorEmbed from './errorEmbed.js';
|
||||
|
||||
export const noMember = errorEmbed(
|
||||
'User of command is not a member',
|
||||
'Discord claims that the user of this command does not have an account... strange!',
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
import errorEmbed from './errorEmbed.js';
|
||||
|
||||
export const notTrackedByBlitzStars = errorEmbed(
|
||||
'No data to display',
|
||||
'Player is not tracked by BlitzStars.',
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { SKILLED_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function sklldEmbed(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(SKILLED_COLOR)
|
||||
.setTitle(title)
|
||||
.setDescription(description);
|
||||
}
|
||||
Reference in new issue
Block a user