mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: player clan data typings
This commit is contained in:
1 parent
ab88be7c94
commit
3cd52b2688
8 files changed
+31
-18
No files matched your search
@@ -38,7 +38,7 @@ try {
|
||||
const data = (await rest.put(
|
||||
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
||||
{ body: commands },
|
||||
)) as { length: number };
|
||||
)) as RESTPostAPIChatInputApplicationCommandsJSONBody[];
|
||||
|
||||
console.log(`Successfully reloaded ${data.length} command(s).`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -11,8 +11,6 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||
|
||||
export const inDev = true;
|
||||
|
||||
export const CLANS = {
|
||||
sklld: {
|
||||
name: 'Skilled',
|
||||
|
||||
@@ -10,8 +10,6 @@ import { ClanDetails } from '../types/clanDetails.js';
|
||||
import { PlayerPersonalData } from '../types/playerPersonalData.js';
|
||||
import { CLANS } from './eligible.js';
|
||||
|
||||
export const inDev = true;
|
||||
|
||||
const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export async function execute(
|
||||
@@ -28,7 +26,7 @@ export async function execute(
|
||||
).json()) as ClanDetails;
|
||||
const clan = clanData.data[CLANS[clanName].id];
|
||||
const memberIds = clan.members_ids;
|
||||
const accountInfo = (await (
|
||||
const playerPersonalData = (await (
|
||||
await fetch(
|
||||
`https://api.wotblitz.com/wotb/account/info/?application_id=${
|
||||
process.env.WARGAMING_APPLICATION_ID
|
||||
@@ -38,10 +36,10 @@ export async function execute(
|
||||
|
||||
const inactiveInfo = memberIds
|
||||
.map((memberId) => {
|
||||
const member = accountInfo.data[memberId];
|
||||
const member = playerPersonalData.data[memberId];
|
||||
const inactiveDays = (time - member.last_battle_time) / 60 / 60 / 24;
|
||||
|
||||
return [member.nickname, inactiveDays] as [string, number];
|
||||
return [member.nickname, inactiveDays] as const;
|
||||
})
|
||||
.filter(([, inactiveDays]) => inactiveDays >= threshold)
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
|
||||
@@ -11,8 +11,6 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||
|
||||
export const inDev = true;
|
||||
|
||||
export async function execute(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
) {
|
||||
|
||||
@@ -8,10 +8,9 @@ import fetch from 'node-fetch';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||
import { SERVERS } from '../constants/servers.js';
|
||||
import { PlayerClanData } from '../types/playerClanData.js';
|
||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||
|
||||
export const inDev = true;
|
||||
|
||||
export async function execute(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
) {
|
||||
@@ -24,11 +23,9 @@ export async function execute(
|
||||
// good match
|
||||
const clanData = (await fetch(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${process.env.WARGAMING_APPLICATION_ID}&account_id=${account.account_id}&extra=clan`,
|
||||
).then((response) => response.json())) as {
|
||||
data: { [key: number]: { clan: { tag: string } | null } };
|
||||
};
|
||||
).then((response) => response.json())) as PlayerClanData;
|
||||
const clan = clanData.data[account.account_id].clan;
|
||||
const clanTag = clan === null ? '' : ` [${clan.tag}]`;
|
||||
const clanTag = clan === null ? '' : ` [${clan!.tag}]`;
|
||||
|
||||
if (interaction.member && interaction.guild) {
|
||||
const member = interaction.guild?.members.cache.get(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { WargamingResponse } from './wargamingResponse.js';
|
||||
|
||||
export interface ClanDetails extends WargamingResponse {
|
||||
data: {
|
||||
[key: number]: {
|
||||
[accountId: number]: {
|
||||
recruiting_options: {
|
||||
vehicles_level: number;
|
||||
wins_ratio: number;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { WargamingResponse } from './wargamingResponse.js';
|
||||
|
||||
export interface PlayerClanData extends WargamingResponse {
|
||||
data: {
|
||||
[accountId: number]: {
|
||||
account_id: number;
|
||||
joined_at: number;
|
||||
clan_id: number;
|
||||
role: string;
|
||||
account_name: string;
|
||||
|
||||
clan?: {
|
||||
members_count: number;
|
||||
name: string;
|
||||
created_at: number;
|
||||
tag: string;
|
||||
clan_id: number;
|
||||
emblem_set_id: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { WargamingResponse } from './wargamingResponse.js';
|
||||
|
||||
export interface PlayerPersonalData extends WargamingResponse {
|
||||
data: {
|
||||
[key: number]: {
|
||||
[accountId: number]: {
|
||||
statistics: {
|
||||
clan: {
|
||||
spotted: number;
|
||||
|
||||
Reference in new issue
Block a user