mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: added more mature secrets handling
This commit is contained in:
1 parent
c72bfa9f71
commit
eca7cbbbeb
26 files changed
+81
-75
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { Client, GatewayIntentBits } from 'discord.js';
|
import { Client, GatewayIntentBits } from 'discord.js';
|
||||||
import { DISCORD_TOKEN } from './core/node/arguments';
|
import { secrets } from './core/node/secrets';
|
||||||
import { registerErrorHandlers } from './events/error';
|
import { registerErrorHandlers } from './events/error';
|
||||||
import guildMemberAdd from './events/guildMemberAdd';
|
import guildMemberAdd from './events/guildMemberAdd';
|
||||||
import interactionCreate from './events/interactionCreate';
|
import interactionCreate from './events/interactionCreate';
|
||||||
@@ -13,4 +13,4 @@ export const client = new Client({
|
|||||||
.on('interactionCreate', interactionCreate);
|
.on('interactionCreate', interactionCreate);
|
||||||
|
|
||||||
registerErrorHandlers();
|
registerErrorHandlers();
|
||||||
client.login(DISCORD_TOKEN);
|
client.login(secrets.DISCORD_TOKEN);
|
||||||
@@ -12,7 +12,7 @@ import embedNegative from '../core/discord/embedNegative';
|
|||||||
import embedPositive from '../core/discord/embedPositive';
|
import embedPositive from '../core/discord/embedPositive';
|
||||||
import markdownTable, { TableInput } from '../core/discord/markdownTable';
|
import markdownTable, { TableInput } from '../core/discord/markdownTable';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||||
@@ -51,7 +51,7 @@ export const eligibleCommand: CommandRegistry = {
|
|||||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||||
const { id, region: server } = await resolvePlayerFromCommand(interaction);
|
const { id, region: server } = await resolvePlayerFromCommand(interaction);
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const problems: TableInput = [];
|
const problems: TableInput = [];
|
||||||
const title = `${accountInfo[id].nickname}'s eligibility for ${SKILLED_CLANS[clan]}`;
|
const title = `${accountInfo[id].nickname}'s eligibility for ${SKILLED_CLANS[clan]}`;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
|||||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import evolution from '../renderers/evolution';
|
import evolution from '../renderers/evolution';
|
||||||
import { StatType } from '../renderers/fullStats';
|
import { StatType } from '../renderers/fullStats';
|
||||||
@@ -42,7 +42,7 @@ export const evolutionCommand: CommandRegistry = {
|
|||||||
const end = interaction.options.getInteger('end');
|
const end = interaction.options.getInteger('end');
|
||||||
const { nickname } = (
|
const { nickname } = (
|
||||||
await getWargamingResponse<AccountInfo>(
|
await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||||
)
|
)
|
||||||
)[player.id];
|
)[player.id];
|
||||||
const path = interactionToURL(interaction, {
|
const path = interactionToURL(interaction, {
|
||||||
@@ -75,7 +75,7 @@ export const evolutionCommand: CommandRegistry = {
|
|||||||
const path = url.pathname.split('/').filter(Boolean);
|
const path = url.pathname.split('/').filter(Boolean);
|
||||||
const commandGroup = path[1] as StatType;
|
const commandGroup = path[1] as StatType;
|
||||||
const player = await resolvePlayerFromButton(interaction);
|
const player = await resolvePlayerFromButton(interaction);
|
||||||
const period = resolvePeriodFromButton(player.server, interaction);
|
const period = resolvePeriodFromButton(player.region, interaction);
|
||||||
|
|
||||||
return await evolution(
|
return await evolution(
|
||||||
commandGroup,
|
commandGroup,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
|||||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import fullStats, { StatType } from '../renderers/fullStats';
|
import fullStats, { StatType } from '../renderers/fullStats';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
@@ -47,7 +47,7 @@ export const fullStatsCommand: CommandRegistry = {
|
|||||||
});
|
});
|
||||||
const { nickname } = (
|
const { nickname } = (
|
||||||
await getWargamingResponse<AccountInfo>(
|
await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||||
)
|
)
|
||||||
)[player.id];
|
)[player.id];
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ export const fullStatsCommand: CommandRegistry = {
|
|||||||
const path = url.pathname.split('/').filter(Boolean);
|
const path = url.pathname.split('/').filter(Boolean);
|
||||||
const commandGroup = path[1] as StatType;
|
const commandGroup = path[1] as StatType;
|
||||||
const player = await resolvePlayerFromButton(interaction);
|
const player = await resolvePlayerFromButton(interaction);
|
||||||
const period = resolvePeriodFromButton(player.server, interaction);
|
const period = resolvePeriodFromButton(player.region, interaction);
|
||||||
|
|
||||||
return await fullStats(
|
return await fullStats(
|
||||||
commandGroup,
|
commandGroup,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import getBlitzClan from '../core/blitz/getBlitzClan';
|
|||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
||||||
import addClanChoices from '../core/discord/addClanChoices';
|
import addClanChoices from '../core/discord/addClanChoices';
|
||||||
import autocompleteClan from '../core/discord/autocompleteClan';
|
import autocompleteClan from '../core/discord/autocompleteClan';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
import { ClanInfo } from '../types/clanInfo';
|
import { ClanInfo } from '../types/clanInfo';
|
||||||
@@ -42,14 +42,14 @@ export const inactiveCommand: CommandRegistry = {
|
|||||||
const time = new Date().getTime() / 1000;
|
const time = new Date().getTime() / 1000;
|
||||||
const clanData = (
|
const clanData = (
|
||||||
await getWargamingResponse<ClanInfo>(
|
await getWargamingResponse<ClanInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&clan_id=${id}`,
|
||||||
)
|
)
|
||||||
)[id];
|
)[id];
|
||||||
const memberIds = clanData.members_ids;
|
const memberIds = clanData.members_ids;
|
||||||
const accounts = await getWargamingResponse<AccountInfo>(
|
const accounts = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${memberIds.join(
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${
|
||||||
',',
|
secrets.WARGAMING_APPLICATION_ID
|
||||||
)}`,
|
}&account_id=${memberIds.join(',')}`,
|
||||||
);
|
);
|
||||||
const inactive = memberIds
|
const inactive = memberIds
|
||||||
.map((memberId) => {
|
.map((memberId) => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
import { PlayerClanData } from '../types/playerClanData';
|
import { PlayerClanData } from '../types/playerClanData';
|
||||||
@@ -76,7 +76,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
const account = await resolvePlayerFromCommand(interaction);
|
const account = await resolvePlayerFromCommand(interaction);
|
||||||
const { id, region: server } = account;
|
const { id, region: server } = account;
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const tankStats = await getTankStats(server, id);
|
const tankStats = await getTankStats(server, id);
|
||||||
const tanks = (
|
const tanks = (
|
||||||
@@ -88,7 +88,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
)
|
)
|
||||||
).filter((tank) => tank?.tier === tier);
|
).filter((tank) => tank?.tier === tier);
|
||||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const leftColumnSize = Math.ceil(tanks.length / 2);
|
const leftColumnSize = Math.ceil(tanks.length / 2);
|
||||||
const leftColumn = tanks.slice(0, leftColumnSize);
|
const leftColumn = tanks.slice(0, leftColumnSize);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import autocompleteUsername from '../core/discord/autocompleteUsername';
|
|||||||
import embedInfo from '../core/discord/embedInfo';
|
import embedInfo from '../core/discord/embedInfo';
|
||||||
import markdownTable, { TableInputEntry } from '../core/discord/markdownTable';
|
import markdownTable, { TableInputEntry } from '../core/discord/markdownTable';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountAchievements } from '../types/accountAchievements';
|
import { AccountAchievements } from '../types/accountAchievements';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
@@ -38,11 +38,11 @@ export const playerAchievementsCommand: CommandRegistry = {
|
|||||||
const account = await resolvePlayerFromCommand(interaction);
|
const account = await resolvePlayerFromCommand(interaction);
|
||||||
const { id, region: server } = account;
|
const { id, region: server } = account;
|
||||||
const accounts = await getWargamingResponse<AccountInfo>(
|
const accounts = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const accountsAchievements =
|
const accountsAchievements =
|
||||||
await getWargamingResponse<AccountAchievements>(
|
await getWargamingResponse<AccountAchievements>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/achievements/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const accountAchievements = accountsAchievements[id];
|
const accountAchievements = accountsAchievements[id];
|
||||||
const compound = {
|
const compound = {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import autocompleteUsername from '../core/discord/autocompleteUsername';
|
|||||||
import embedInfo from '../core/discord/embedInfo';
|
import embedInfo from '../core/discord/embedInfo';
|
||||||
import markdownTable from '../core/discord/markdownTable';
|
import markdownTable from '../core/discord/markdownTable';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ export const playerInfoCommand: CommandRegistry = {
|
|||||||
const account = await resolvePlayerFromCommand(interaction);
|
const account = await resolvePlayerFromCommand(interaction);
|
||||||
const { id, region: server } = account;
|
const { id, region: server } = account;
|
||||||
const accounts = await getWargamingResponse<AccountInfo>(
|
const accounts = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const accountInfo = accounts[id];
|
const accountInfo = accounts[id];
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
|||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ export const ratingsCommand: CommandRegistry = {
|
|||||||
`https://${regionSubdomain}.wotblitz.com/en/api/rating-leaderboards/league/${leagueIndex}/top/`,
|
`https://${regionSubdomain}.wotblitz.com/en/api/rating-leaderboards/league/${leagueIndex}/top/`,
|
||||||
).then((response) => response.json() as Promise<LeagueTop>);
|
).then((response) => response.json() as Promise<LeagueTop>);
|
||||||
const { nickname } = await getWargamingResponse<AccountInfo>(
|
const { nickname } = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||||
).then((accounts) => accounts[player.id]);
|
).then((accounts) => accounts[player.id]);
|
||||||
const awaitedInfo = await ratingsInfo;
|
const awaitedInfo = await ratingsInfo;
|
||||||
const leagueInfo = awaitedInfo.leagues[leagueIndex];
|
const leagueInfo = awaitedInfo.leagues[leagueIndex];
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
|||||||
import addClanChoices from '../core/discord/addClanChoices';
|
import addClanChoices from '../core/discord/addClanChoices';
|
||||||
import addServerChoices from '../core/discord/addServerChoices';
|
import addServerChoices from '../core/discord/addServerChoices';
|
||||||
import embedInfo from '../core/discord/embedInfo';
|
import embedInfo from '../core/discord/embedInfo';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { ClanList } from '../types/clanList';
|
import { ClanList } from '../types/clanList';
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ export const searchClansCommand: CommandRegistry = {
|
|||||||
const clan = interaction.options.getString('clan')!;
|
const clan = interaction.options.getString('clan')!;
|
||||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||||
const clanList = await getWargamingResponse<ClanList>(
|
const clanList = await getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return embedInfo(
|
return embedInfo(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { usernamePattern } from '../core/blitz/listPlayers';
|
|||||||
import addServerChoices from '../core/discord/addServerChoices';
|
import addServerChoices from '../core/discord/addServerChoices';
|
||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import embedInfo from '../core/discord/embedInfo';
|
import embedInfo from '../core/discord/embedInfo';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountList } from '../types/accountList';
|
import { AccountList } from '../types/accountList';
|
||||||
|
|
||||||
@@ -37,9 +37,9 @@ export const searchPlayersCommand: CommandRegistry = {
|
|||||||
const trimmedSearch = name.trim();
|
const trimmedSearch = name.trim();
|
||||||
const players = usernamePattern.test(trimmedSearch)
|
const players = usernamePattern.test(trimmedSearch)
|
||||||
? await getWargamingResponse<AccountList>(
|
? await getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodeURIComponent(
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${
|
||||||
trimmedSearch,
|
secrets.WARGAMING_APPLICATION_ID
|
||||||
)}&limit=${limit}`,
|
}&search=${encodeURIComponent(trimmedSearch)}&limit=${limit}`,
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
|||||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { StatType } from '../renderers/fullStats';
|
import { StatType } from '../renderers/fullStats';
|
||||||
import stats from '../renderers/stats';
|
import stats from '../renderers/stats';
|
||||||
@@ -48,7 +48,7 @@ export const statsCommand: CommandRegistry = {
|
|||||||
});
|
});
|
||||||
const { nickname } = (
|
const { nickname } = (
|
||||||
await getWargamingResponse<AccountInfo>(
|
await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||||
)
|
)
|
||||||
)[player.id];
|
)[player.id];
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ export const statsCommand: CommandRegistry = {
|
|||||||
const path = url.pathname.split('/').filter(Boolean);
|
const path = url.pathname.split('/').filter(Boolean);
|
||||||
const commandGroup = path[1] as StatType;
|
const commandGroup = path[1] as StatType;
|
||||||
const player = await resolvePlayerFromButton(interaction);
|
const player = await resolvePlayerFromButton(interaction);
|
||||||
const period = resolvePeriodFromButton(player.server, interaction);
|
const period = resolvePeriodFromButton(player.region, interaction);
|
||||||
|
|
||||||
return await stats(
|
return await stats(
|
||||||
commandGroup,
|
commandGroup,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import linkButton from '../core/discord/linkButton';
|
|||||||
import primaryButton from '../core/discord/primaryButton';
|
import primaryButton from '../core/discord/primaryButton';
|
||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import today from '../renderers/today';
|
import today from '../renderers/today';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
@@ -37,7 +37,7 @@ export const todayCommand: CommandRegistry = {
|
|||||||
const limit = interaction.options.getInteger('limit') ?? Infinity;
|
const limit = interaction.options.getInteger('limit') ?? Infinity;
|
||||||
const { nickname } = (
|
const { nickname } = (
|
||||||
await getWargamingResponse<AccountInfo>(
|
await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
`https://api.wotblitz.${player.region}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||||
)
|
)
|
||||||
)[player.id];
|
)[player.id];
|
||||||
const path = interactionToURL(interaction, player);
|
const path = interactionToURL(interaction, player);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import autocompleteUsername from '../core/discord/autocompleteUsername';
|
|||||||
import embedNegative from '../core/discord/embedNegative';
|
import embedNegative from '../core/discord/embedNegative';
|
||||||
import embedPositive from '../core/discord/embedPositive';
|
import embedPositive from '../core/discord/embedPositive';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
import { PlayerClanData } from '../types/playerClanData';
|
import { PlayerClanData } from '../types/playerClanData';
|
||||||
@@ -26,10 +26,10 @@ export const verifyCommand: CommandRegistry = {
|
|||||||
const blitzAccount = await resolvePlayerFromCommand(interaction);
|
const blitzAccount = await resolvePlayerFromCommand(interaction);
|
||||||
const { id, region: server } = blitzAccount;
|
const { id, region: server } = blitzAccount;
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const clan = clanData[id]?.clan;
|
const clan = clanData[id]?.clan;
|
||||||
const clanTag = clan ? ` [${clan!.tag}]` : '';
|
const clanTag = clan ? ` [${clan!.tag}]` : '';
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { REGION_NAMES, Region } from '../../constants/regions';
|
import { REGION_NAMES, Region } from '../../constants/regions';
|
||||||
import { TanksStats } from '../../types/tanksStats';
|
import { TanksStats } from '../../types/tanksStats';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
import { secrets } from '../node/secrets';
|
||||||
import throwError from '../node/throwError';
|
import throwError from '../node/throwError';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
import getWargamingResponse from './getWargamingResponse';
|
||||||
|
|
||||||
export default async function getTankStats(server: Region, id: number) {
|
export default async function getTankStats(server: Region, id: number) {
|
||||||
const tankStats = await getWargamingResponse<TanksStats>(
|
const tankStats = await getWargamingResponse<TanksStats>(
|
||||||
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tankStats[id] === null) {
|
if (tankStats[id] === null) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { Clan, ClanList } from '../../types/clanList';
|
import { Clan, ClanList } from '../../types/clanList';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
import { secrets } from '../node/secrets';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
import getWargamingResponse from './getWargamingResponse';
|
||||||
|
|
||||||
export type ClanListWithServer = (Clan & {
|
export type ClanListWithServer = (Clan & {
|
||||||
@@ -15,7 +15,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
return (
|
return (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getWargamingResponse<ClanList>(
|
getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.com/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -25,7 +25,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -35,7 +35,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { Account, AccountList } from '../../types/accountList';
|
import { Account, AccountList } from '../../types/accountList';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
import { secrets } from '../node/secrets';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
import getWargamingResponse from './getWargamingResponse';
|
||||||
|
|
||||||
export type AccountListWithServer = (Account & {
|
export type AccountListWithServer = (Account & {
|
||||||
@@ -19,7 +19,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
return (
|
return (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getWargamingResponse<AccountList>(
|
getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.com/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -29,7 +29,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.eu/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -39,7 +39,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.asia/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/account/list/?application_id=${secrets.WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
getHistoriesDefaultOptions,
|
getHistoriesDefaultOptions,
|
||||||
} from '../../types/histories';
|
} from '../../types/histories';
|
||||||
import getWargamingResponse from '../blitz/getWargamingResponse';
|
import getWargamingResponse from '../blitz/getWargamingResponse';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments';
|
import { secrets } from '../node/secrets';
|
||||||
import { emptyAllStats } from './getDiffedTankStats';
|
import { emptyAllStats } from './getDiffedTankStats';
|
||||||
|
|
||||||
export interface PlayerHistoryRaw {
|
export interface PlayerHistoryRaw {
|
||||||
@@ -67,7 +67,7 @@ export default async function getPlayerHistories(
|
|||||||
statistics: { all },
|
statistics: { all },
|
||||||
} = (
|
} = (
|
||||||
await getWargamingResponse<AccountInfo>(
|
await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
)
|
)
|
||||||
)[id];
|
)[id];
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
export const DISCORD_TOKEN = process.env.DISCORD_TOKEN!;
|
|
||||||
export const WARGAMING_APPLICATION_ID = process.env.WARGAMING_APPLICATION_ID!;
|
|
||||||
|
|
||||||
if (!DISCORD_TOKEN) {
|
|
||||||
throw new Error('No Discord token provided');
|
|
||||||
}
|
|
||||||
if (!WARGAMING_APPLICATION_ID) {
|
|
||||||
throw new Error('No Wargaming application id provided}');
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
const SECRET_KEYS = ['DISCORD_TOKEN', 'WARGAMING_APPLICATION_ID'] as const;
|
||||||
|
|
||||||
|
type SECRET_KEY = typeof SECRET_KEYS extends readonly (infer T)[] ? T : never;
|
||||||
|
|
||||||
|
export const secrets = SECRET_KEYS.reduce<Partial<Record<SECRET_KEY, string>>>(
|
||||||
|
(accumulator, key) => ({
|
||||||
|
...accumulator,
|
||||||
|
|
||||||
|
get [key](): string {
|
||||||
|
if (!(key in process.env)) throw new Error(`Key ${key} not provided`);
|
||||||
|
return process.env[key]!;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{},
|
||||||
|
) as Record<SECRET_KEY, string>;
|
||||||
@@ -30,9 +30,9 @@ import { searchTanksCommand } from '../../commands/searchTanks';
|
|||||||
import { statsCommand } from '../../commands/stats';
|
import { statsCommand } from '../../commands/stats';
|
||||||
import { todayCommand } from '../../commands/today';
|
import { todayCommand } from '../../commands/today';
|
||||||
import { verifyCommand } from '../../commands/verify';
|
import { verifyCommand } from '../../commands/verify';
|
||||||
import { DISCORD_TOKEN } from '../../core/node/arguments';
|
|
||||||
import getClientId from '../../core/node/getClientId';
|
import getClientId from '../../core/node/getClientId';
|
||||||
import isDev from '../../core/node/isDev';
|
import isDev from '../../core/node/isDev';
|
||||||
|
import { secrets } from '../../core/node/secrets';
|
||||||
import handleAutocomplete from './handlers/autocomplete';
|
import handleAutocomplete from './handlers/autocomplete';
|
||||||
import handleButton from './handlers/button';
|
import handleButton from './handlers/button';
|
||||||
import handleChatInputCommand from './handlers/chatInputCommand';
|
import handleChatInputCommand from './handlers/chatInputCommand';
|
||||||
@@ -71,7 +71,7 @@ export interface CommandRegistry<HandlesInteraction extends boolean = boolean>
|
|||||||
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rest = new REST().setToken(DISCORD_TOKEN);
|
const rest = new REST().setToken(secrets.DISCORD_TOKEN);
|
||||||
|
|
||||||
export const COMMANDS_RAW: CommandRegistry[] = [
|
export const COMMANDS_RAW: CommandRegistry[] = [
|
||||||
debugCommand,
|
debugCommand,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import getPlayerHistories from '../core/blitzstars/getPlayerHistories';
|
|||||||
import getTankHistories from '../core/blitzstars/getTankHistories';
|
import getTankHistories from '../core/blitzstars/getTankHistories';
|
||||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
import { Histories } from '../types/histories';
|
import { Histories } from '../types/histories';
|
||||||
import { PlayerClanData } from '../types/playerClanData';
|
import { PlayerClanData } from '../types/playerClanData';
|
||||||
@@ -29,7 +29,7 @@ export default async function evolution<Type extends StatType>(
|
|||||||
if (type === 'player') {
|
if (type === 'player') {
|
||||||
const clan = (
|
const clan = (
|
||||||
await getWargamingResponse<PlayerClanData>(
|
await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
)
|
)
|
||||||
)[id]?.clan;
|
)[id]?.clan;
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ export default async function evolution<Type extends StatType>(
|
|||||||
const minX = Math.min(...xs);
|
const minX = Math.min(...xs);
|
||||||
|
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
|||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import {
|
import {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
AllStats,
|
AllStats,
|
||||||
@@ -37,7 +37,7 @@ export default async function fullStats<Type extends StatType>(
|
|||||||
if (type === 'player') {
|
if (type === 'player') {
|
||||||
const clan = (
|
const clan = (
|
||||||
await getWargamingResponse<PlayerClanData>(
|
await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
)
|
)
|
||||||
)[id]?.clan;
|
)[id]?.clan;
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ export default async function fullStats<Type extends StatType>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
|||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
|
||||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { theme } from '../stitches.config';
|
import { theme } from '../stitches.config';
|
||||||
import {
|
import {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
@@ -39,7 +39,7 @@ export default async function stats<Type extends StatType>(
|
|||||||
if (type === 'player') {
|
if (type === 'player') {
|
||||||
const clan = (
|
const clan = (
|
||||||
await getWargamingResponse<PlayerClanData>(
|
await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
)
|
)
|
||||||
)[id]?.clan;
|
)[id]?.clan;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ export default async function stats<Type extends StatType>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const overview = (
|
const overview = (
|
||||||
<AllStatsOverview stats={stats} supplementaryStats={supplementaryStats} />
|
<AllStatsOverview stats={stats} supplementaryStats={supplementaryStats} />
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import getPeriodNow from '../core/blitzstars/getPeriodNow';
|
|||||||
import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo';
|
import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo';
|
||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
|
import { secrets } from '../core/node/secrets';
|
||||||
import { AccountInfo, AllStats } from '../types/accountInfo';
|
import { AccountInfo, AllStats } from '../types/accountInfo';
|
||||||
import { PlayerClanData } from '../types/playerClanData';
|
import { PlayerClanData } from '../types/playerClanData';
|
||||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||||
@@ -32,10 +32,10 @@ export default async function today(
|
|||||||
getPeriodNow(),
|
getPeriodNow(),
|
||||||
);
|
);
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${secrets.WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const careerTankStatsRaw = await getTankStats(server, id);
|
const careerTankStatsRaw = await getTankStats(server, id);
|
||||||
const careerStats: Record<number, AllStats> = {
|
const careerStats: Record<number, AllStats> = {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const statsRoute: RouteRegistry = {
|
|||||||
async handler(req) {
|
async handler(req) {
|
||||||
const type = req.params.type as StatType;
|
const type = req.params.type as StatType;
|
||||||
const player = resolvePlayerFromRequest(req);
|
const player = resolvePlayerFromRequest(req);
|
||||||
const period = resolvePeriodFromRequest(player.server, req);
|
const period = resolvePeriodFromRequest(player.region, req);
|
||||||
|
|
||||||
return await stats(
|
return await stats(
|
||||||
type,
|
type,
|
||||||
|
|||||||
Reference in new issue
Block a user