mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: BlitzServer type
This commit is contained in:
1 parent
6870b59b3b
commit
8b77baccab
6 files changed
+27
-33
No files matched your search
@@ -5,7 +5,7 @@ import {
|
|||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
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 { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
import blitzLinks from '../utilities/blitzLinks.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
@@ -26,9 +26,7 @@ export async function execute(
|
|||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString(
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
'server',
|
|
||||||
) as keyof typeof SERVERS;
|
|
||||||
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
@@ -140,9 +138,9 @@ export const data = new SlashCommandBuilder()
|
|||||||
.setName('server')
|
.setName('server')
|
||||||
.setDescription('The Blitz server you are in')
|
.setDescription('The Blitz server you are in')
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: SERVERS.com, value: 'com' },
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
{ name: SERVERS.eu, value: 'eu' },
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
{ name: SERVERS.asia, value: 'asia' },
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
)
|
)
|
||||||
.setRequired(true),
|
.setRequired(true),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,19 +4,17 @@ import {
|
|||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { SERVERS } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { TanksStats } from '../types/tanksStats.js';
|
import { TanksStats } from '../types/tanksStats.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
import { tankTypeEmojis, tankopedia } from '../utilities/tankopedia.js';
|
import { tankTypeEmojis, tankopedia } from '../utilities/tankopedia.js';
|
||||||
import fetch from 'node-fetch';
|
|
||||||
|
|
||||||
export async function execute(
|
export async function execute(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
const server = interaction.options.getString(
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
'server',
|
|
||||||
) as keyof typeof SERVERS;
|
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
let tier = interaction.options.getNumber('tier');
|
let tier = interaction.options.getNumber('tier');
|
||||||
|
|
||||||
@@ -92,9 +90,9 @@ export const data = new SlashCommandBuilder()
|
|||||||
.setDescription('The Blitz server you are in')
|
.setDescription('The Blitz server you are in')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: SERVERS.com, value: 'com' },
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
{ name: SERVERS.eu, value: 'eu' },
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
{ name: SERVERS.asia, value: 'asia' },
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { SERVERS } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
import blitzLinks from '../utilities/blitzLinks.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
@@ -15,9 +15,7 @@ export async function execute(
|
|||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString(
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
'server',
|
|
||||||
) as keyof typeof SERVERS;
|
|
||||||
const period = interaction.options.getString('period')! as
|
const period = interaction.options.getString('period')! as
|
||||||
| '30'
|
| '30'
|
||||||
| '90'
|
| '90'
|
||||||
@@ -111,9 +109,9 @@ export const data = new SlashCommandBuilder()
|
|||||||
.setName('server')
|
.setName('server')
|
||||||
.setDescription('The Blitz server you are in')
|
.setDescription('The Blitz server you are in')
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: SERVERS.com, value: 'com' },
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
{ name: SERVERS.eu, value: 'eu' },
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
{ name: SERVERS.asia, value: 'asia' },
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
)
|
)
|
||||||
.setRequired(true),
|
.setRequired(true),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
import fetch from 'node-fetch';
|
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 { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { PlayerClanData } from '../types/playerClanData.js';
|
import { PlayerClanData } from '../types/playerClanData.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
|
|
||||||
@@ -15,9 +15,7 @@ export async function execute(
|
|||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString(
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
'server',
|
|
||||||
) as keyof typeof SERVERS;
|
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
// good match
|
// good match
|
||||||
@@ -79,9 +77,9 @@ export const data = new SlashCommandBuilder()
|
|||||||
.setDescription('The Blitz server you are in')
|
.setDescription('The Blitz server you are in')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.addChoices(
|
.addChoices(
|
||||||
{ name: SERVERS.com, value: 'com' },
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
{ name: SERVERS.eu, value: 'eu' },
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
{ name: SERVERS.asia, value: 'asia' },
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
export const SERVERS = {
|
export const BLITZ_SERVERS = {
|
||||||
com: 'North America',
|
com: 'North America',
|
||||||
eu: 'Europe',
|
eu: 'Europe',
|
||||||
asia: 'Asia',
|
asia: 'Asia',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type BlitzServer = keyof typeof BLITZ_SERVERS;
|
||||||
@@ -5,16 +5,16 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||||
import { SERVERS } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { Player, Players } from '../types/players.js';
|
import { Player, Players } from '../types/players.js';
|
||||||
|
|
||||||
export default async function getBlitzAccount(
|
export default async function getBlitzAccount(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
ign: string,
|
ign: string,
|
||||||
server: keyof typeof SERVERS,
|
server: BlitzServer,
|
||||||
callback: (account: Player) => void,
|
callback: (account: Player) => void,
|
||||||
) {
|
) {
|
||||||
const serverName = SERVERS[server];
|
const serverName = BLITZ_SERVERS[server];
|
||||||
const players = (await fetch(
|
const players = (await fetch(
|
||||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${process.env.WARGAMING_APPLICATION_ID}&search=${ign}`,
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${process.env.WARGAMING_APPLICATION_ID}&search=${ign}`,
|
||||||
).then((response) => response.json())) as Players;
|
).then((response) => response.json())) as Players;
|
||||||
|
|||||||
Reference in new issue
Block a user