mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +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(
|
const data = (await rest.put(
|
||||||
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
||||||
{ body: commands },
|
{ body: commands },
|
||||||
)) as { length: number };
|
)) as RESTPostAPIChatInputApplicationCommandsJSONBody[];
|
||||||
|
|
||||||
console.log(`Successfully reloaded ${data.length} command(s).`);
|
console.log(`Successfully reloaded ${data.length} command(s).`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||||
|
|
||||||
export const inDev = true;
|
|
||||||
|
|
||||||
export const CLANS = {
|
export const CLANS = {
|
||||||
sklld: {
|
sklld: {
|
||||||
name: 'Skilled',
|
name: 'Skilled',
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import { ClanDetails } from '../types/clanDetails.js';
|
|||||||
import { PlayerPersonalData } from '../types/playerPersonalData.js';
|
import { PlayerPersonalData } from '../types/playerPersonalData.js';
|
||||||
import { CLANS } from './eligible.js';
|
import { CLANS } from './eligible.js';
|
||||||
|
|
||||||
export const inDev = true;
|
|
||||||
|
|
||||||
const DEFAULT_THRESHOLD = 7;
|
const DEFAULT_THRESHOLD = 7;
|
||||||
|
|
||||||
export async function execute(
|
export async function execute(
|
||||||
@@ -28,7 +26,7 @@ export async function execute(
|
|||||||
).json()) as ClanDetails;
|
).json()) as ClanDetails;
|
||||||
const clan = clanData.data[CLANS[clanName].id];
|
const clan = clanData.data[CLANS[clanName].id];
|
||||||
const memberIds = clan.members_ids;
|
const memberIds = clan.members_ids;
|
||||||
const accountInfo = (await (
|
const playerPersonalData = (await (
|
||||||
await fetch(
|
await fetch(
|
||||||
`https://api.wotblitz.com/wotb/account/info/?application_id=${
|
`https://api.wotblitz.com/wotb/account/info/?application_id=${
|
||||||
process.env.WARGAMING_APPLICATION_ID
|
process.env.WARGAMING_APPLICATION_ID
|
||||||
@@ -38,10 +36,10 @@ export async function execute(
|
|||||||
|
|
||||||
const inactiveInfo = memberIds
|
const inactiveInfo = memberIds
|
||||||
.map((memberId) => {
|
.map((memberId) => {
|
||||||
const member = accountInfo.data[memberId];
|
const member = playerPersonalData.data[memberId];
|
||||||
const inactiveDays = (time - member.last_battle_time) / 60 / 60 / 24;
|
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)
|
.filter(([, inactiveDays]) => inactiveDays >= threshold)
|
||||||
.sort((a, b) => b[1] - a[1])
|
.sort((a, b) => b[1] - a[1])
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||||
|
|
||||||
export const inDev = true;
|
|
||||||
|
|
||||||
export async function execute(
|
export async function execute(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ import fetch from 'node-fetch';
|
|||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { SERVERS } from '../constants/servers.js';
|
import { SERVERS } from '../constants/servers.js';
|
||||||
|
import { PlayerClanData } from '../types/playerClanData.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
|
|
||||||
export const inDev = true;
|
|
||||||
|
|
||||||
export async function execute(
|
export async function execute(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
@@ -24,11 +23,9 @@ export async function execute(
|
|||||||
// good match
|
// good match
|
||||||
const clanData = (await fetch(
|
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`,
|
`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 {
|
).then((response) => response.json())) as PlayerClanData;
|
||||||
data: { [key: number]: { clan: { tag: string } | null } };
|
|
||||||
};
|
|
||||||
const clan = clanData.data[account.account_id].clan;
|
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) {
|
if (interaction.member && interaction.guild) {
|
||||||
const member = interaction.guild?.members.cache.get(
|
const member = interaction.guild?.members.cache.get(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { WargamingResponse } from './wargamingResponse.js';
|
|||||||
|
|
||||||
export interface ClanDetails extends WargamingResponse {
|
export interface ClanDetails extends WargamingResponse {
|
||||||
data: {
|
data: {
|
||||||
[key: number]: {
|
[accountId: number]: {
|
||||||
recruiting_options: {
|
recruiting_options: {
|
||||||
vehicles_level: number;
|
vehicles_level: number;
|
||||||
wins_ratio: 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 {
|
export interface PlayerPersonalData extends WargamingResponse {
|
||||||
data: {
|
data: {
|
||||||
[key: number]: {
|
[accountId: number]: {
|
||||||
statistics: {
|
statistics: {
|
||||||
clan: {
|
clan: {
|
||||||
spotted: number;
|
spotted: number;
|
||||||
|
|||||||
Reference in new issue
Block a user