mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Merge pull request #8 from tresabhi/1.7.5
This commit is contained in:
22 files changed
+89
-77
No files matched your search
+15
-24
@@ -8,40 +8,31 @@ on:
|
|||||||
- 'main'
|
- 'main'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
host:
|
host:
|
||||||
name: Host
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Get code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install Yarn
|
- name: Get latest release
|
||||||
run: npm install --location=global yarn
|
uses: actions/github-script@v4
|
||||||
|
|
||||||
- name: Use node_modules cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: '**/node_modules'
|
script: |
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
const response = await github.repos.getLatestRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
});
|
||||||
|
console.log(response.data.assets[0].browser_download_url);
|
||||||
|
core.setOutput("download_url", response.data.assets[0].browser_download_url);
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Download release assets
|
||||||
run: yarn
|
run: |
|
||||||
|
curl -L -o dist.zip ${{ steps.get-latest-release.outputs.download_url }}
|
||||||
|
unzip dist.zip
|
||||||
|
|
||||||
- name: Host
|
- name: Run index.cjs
|
||||||
run: NODE_ENV=production DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ secrets.WARGAMING_APPLICATION_ID }} yarn dev --dev
|
run: NODE_ENV=production DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ secrets.WARGAMING_APPLICATION_ID }} node --enable-source-maps dist/index.cjs
|
||||||
@@ -6,3 +6,4 @@ package-lock.json
|
|||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
dist/
|
dist/
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
dist.zip
|
||||||
Vendored
+1
@@ -6,6 +6,7 @@
|
|||||||
"cleandist",
|
"cleandist",
|
||||||
"fuzzysort",
|
"fuzzysort",
|
||||||
"kranvagn",
|
"kranvagn",
|
||||||
|
"outfile",
|
||||||
"ownedtanks",
|
"ownedtanks",
|
||||||
"Resvg",
|
"Resvg",
|
||||||
"searchplayers",
|
"searchplayers",
|
||||||
|
|||||||
+3
-5
@@ -6,11 +6,9 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "yarn build && yarn start",
|
"dev": "yarn build && yarn start",
|
||||||
"start": "node --enable-source-maps dist/server.cjs",
|
"start": "node --enable-source-maps dist/index.cjs",
|
||||||
"cleandist": "rm -rf dist",
|
"zip": "zip -r dist.zip dist",
|
||||||
"build:raw": "npx esbuild src/index.ts --outfile=dist/server.cjs --platform=node --bundle --sourcemap --loader:.node=copy --loader:.ttf=file",
|
"build": "node scripts/build",
|
||||||
"build:package": "cp package.dist.json dist/package.json",
|
|
||||||
"build": "yarn cleandist && yarn build:raw && yarn build:package",
|
|
||||||
"lint": "tsc"
|
"lint": "tsc"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { build } from 'esbuild';
|
||||||
|
import { rmSync } from 'fs';
|
||||||
|
|
||||||
|
console.log('Removing dist...');
|
||||||
|
rmSync('dist', { recursive: true, force: true });
|
||||||
|
|
||||||
|
console.log('Creating context...');
|
||||||
|
build({
|
||||||
|
entryPoints: ['src/index.ts'],
|
||||||
|
outfile: 'dist/index.cjs',
|
||||||
|
|
||||||
|
platform: 'node',
|
||||||
|
loader: {
|
||||||
|
'.node': 'copy',
|
||||||
|
'.ttf': 'file',
|
||||||
|
},
|
||||||
|
|
||||||
|
bundle: true,
|
||||||
|
sourcemap: true,
|
||||||
|
minifyIdentifiers: false, // causes errors
|
||||||
|
minifySyntax: true,
|
||||||
|
minifyWhitespace: true,
|
||||||
|
});
|
||||||
@@ -13,7 +13,7 @@ import cmdName from '../core/interaction/cmdName.js';
|
|||||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||||
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export default {
|
|||||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||||
const { id, server } = await getBlitzAccount(interaction);
|
const { id, server } = await getBlitzAccount(interaction);
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${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]}`;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import getBlitzClan from '../core/blitz/getBlitzClan.js';
|
|||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
import cmdName from '../core/interaction/cmdName.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import addClanChoices from '../core/options/addClanChoices.js';
|
import addClanChoices from '../core/options/addClanChoices.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
@@ -44,12 +44,12 @@ export default {
|
|||||||
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=${wargamingApplicationId}&clan_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${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=${wargamingApplicationId}&account_id=${memberIds.join(
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${memberIds.join(
|
||||||
',',
|
',',
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
|||||||
import { TIER_ROMAN_NUMERALS, tankopedia } from '../core/blitz/tankopedia.js';
|
import { TIER_ROMAN_NUMERALS, tankopedia } from '../core/blitz/tankopedia.js';
|
||||||
import cmdName from '../core/interaction/cmdName.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
@@ -62,14 +62,14 @@ export default {
|
|||||||
const account = await getBlitzAccount(interaction);
|
const account = await getBlitzAccount(interaction);
|
||||||
const { id, server } = account;
|
const { id, server } = account;
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const tankStats = await getTankStats(interaction, server, id);
|
const tankStats = await getTankStats(interaction, server, id);
|
||||||
const tanks = tankStats
|
const tanks = tankStats
|
||||||
.map((tankData) => tankopedia[tankData.tank_id])
|
.map((tankData) => tankopedia[tankData.tank_id])
|
||||||
.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=${wargamingApplicationId}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const image = await render(
|
const image = await render(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import cleanTable, { TableInputEntry } from '../core/interaction/cleanTable.js';
|
|||||||
import cmdName from '../core/interaction/cmdName.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountAchievements } from '../types/accountAchievements.js';
|
import { AccountAchievements } from '../types/accountAchievements.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
@@ -39,11 +39,11 @@ export default {
|
|||||||
const account = await getBlitzAccount(interaction);
|
const account = await getBlitzAccount(interaction);
|
||||||
const { id, server } = account;
|
const { id, server } = account;
|
||||||
const accounts = await getWargamingResponse<AccountInfo>(
|
const accounts = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${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=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const accountAchievements = accountsAchievements[id];
|
const accountAchievements = accountsAchievements[id];
|
||||||
const compound = {
|
const compound = {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import cleanTable from '../core/interaction/cleanTable.js';
|
|||||||
import cmdName from '../core/interaction/cmdName.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export default {
|
|||||||
const account = await getBlitzAccount(interaction);
|
const account = await getBlitzAccount(interaction);
|
||||||
const { id, server } = account;
|
const { id, server } = account;
|
||||||
const accounts = await getWargamingResponse<AccountInfo>(
|
const accounts = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const accountInfo = accounts[id];
|
const accountInfo = accounts[id];
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import cmdName from '../core/interaction/cmdName.js';
|
|||||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||||
import addClanChoices from '../core/options/addClanChoices.js';
|
import addClanChoices from '../core/options/addClanChoices.js';
|
||||||
import addServerChoices from '../core/options/addServerChoices.js';
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { ClanList } from '../types/clanList.js';
|
import { ClanList } from '../types/clanList.js';
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ export default {
|
|||||||
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=${wargamingApplicationId}&search=${clan}&limit=${limit}`,
|
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import cmdName from '../core/interaction/cmdName.js';
|
|||||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||||
import addServerChoices from '../core/options/addServerChoices.js';
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountList } from '../types/accountList.js';
|
import { AccountList } from '../types/accountList.js';
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
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=${wargamingApplicationId}&search=${encodeURIComponent(
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodeURIComponent(
|
||||||
trimmedSearch,
|
trimmedSearch,
|
||||||
)}&limit=${limit}`,
|
)}&limit=${limit}`,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import addStatPeriodChoices, {
|
|||||||
statPeriodNames,
|
statPeriodNames,
|
||||||
} from '../core/options/addStatPeriodChoices.js';
|
} from '../core/options/addStatPeriodChoices.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import {
|
import {
|
||||||
@@ -53,10 +53,10 @@ export default {
|
|||||||
const period = interaction.options.getString('period') as StatPeriod;
|
const period = interaction.options.getString('period') as StatPeriod;
|
||||||
const { id, server } = await getBlitzAccount(interaction);
|
const { id, server } = await getBlitzAccount(interaction);
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${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=${wargamingApplicationId}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const tankStats = await getTankStats(interaction, server, id);
|
const tankStats = await getTankStats(interaction, server, id);
|
||||||
let stats: AllStats;
|
let stats: AllStats;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import addStatPeriodChoices, {
|
|||||||
} from '../core/options/addStatPeriodChoices.js';
|
} from '../core/options/addStatPeriodChoices.js';
|
||||||
import addTankChoices from '../core/options/addTankChoices.js';
|
import addTankChoices from '../core/options/addTankChoices.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
const blitzAccount = await getBlitzAccount(interaction);
|
const blitzAccount = await getBlitzAccount(interaction);
|
||||||
const { id, server } = blitzAccount;
|
const { id, server } = blitzAccount;
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const tankStats = await getTankStats(interaction, server, id);
|
const tankStats = await getTankStats(interaction, server, id);
|
||||||
let stats: AllStats;
|
let stats: AllStats;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import cmdName from '../core/interaction/cmdName.js';
|
|||||||
import fullBlitzStarsStats from '../core/interaction/fullBlitzStarsStats.js';
|
import fullBlitzStarsStats from '../core/interaction/fullBlitzStarsStats.js';
|
||||||
import { supportBlitzStars } from '../core/interaction/supportBlitzStars.js';
|
import { supportBlitzStars } from '../core/interaction/supportBlitzStars.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||||
@@ -50,10 +50,10 @@ export default {
|
|||||||
new Date().getTime() / 1000,
|
new Date().getTime() / 1000,
|
||||||
);
|
);
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${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=${wargamingApplicationId}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const careerTankStatsRaw = await getTankStats(interaction, server, id);
|
const careerTankStatsRaw = await getTankStats(interaction, server, id);
|
||||||
const careerStats: Record<number, AllStats> = {
|
const careerStats: Record<number, AllStats> = {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
|||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
import cmdName from '../core/interaction/cmdName.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||||
import { wargamingApplicationId } from '../core/process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
import { PlayerClanData } from '../types/playerClanData.js';
|
import { PlayerClanData } from '../types/playerClanData.js';
|
||||||
@@ -26,10 +26,10 @@ export default {
|
|||||||
const blitzAccount = await getBlitzAccount(interaction);
|
const blitzAccount = await getBlitzAccount(interaction);
|
||||||
const { id, server } = blitzAccount;
|
const { id, server } = blitzAccount;
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${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=${wargamingApplicationId}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${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,7 +1,7 @@
|
|||||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } 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 { wargamingApplicationId } from '../process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||||
import errorWithCause from '../process/errorWithCause.js';
|
import errorWithCause from '../process/errorWithCause.js';
|
||||||
import getWargamingResponse from './getWargamingResponse.js';
|
import getWargamingResponse from './getWargamingResponse.js';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ export default async function getTankStats(
|
|||||||
id: number,
|
id: number,
|
||||||
) {
|
) {
|
||||||
const tankStats = await getWargamingResponse<TanksStats>(
|
const tankStats = await getWargamingResponse<TanksStats>(
|
||||||
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${wargamingApplicationId}&account_id=${id}`,
|
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tankStats[id] === null) {
|
if (tankStats[id] === null) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BlitzServer } from '../../constants/servers.js';
|
import { BlitzServer } from '../../constants/servers.js';
|
||||||
import { Account, AccountList } from '../../types/accountList.js';
|
import { Account, AccountList } from '../../types/accountList.js';
|
||||||
import { wargamingApplicationId } from '../process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||||
import getWargamingResponse from './getWargamingResponse.js';
|
import getWargamingResponse from './getWargamingResponse.js';
|
||||||
|
|
||||||
export type AccountListWithServer = (Account & {
|
export type AccountListWithServer = (Account & {
|
||||||
@@ -19,7 +19,7 @@ export default async function listAccountsPanServer(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=${wargamingApplicationId}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -29,7 +29,7 @@ export default async function listAccountsPanServer(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.eu/wotb/account/list/?application_id=${wargamingApplicationId}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -39,7 +39,7 @@ export default async function listAccountsPanServer(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
getWargamingResponse<AccountList>(
|
||||||
`https://api.wotblitz.asia/wotb/account/list/?application_id=${wargamingApplicationId}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BlitzServer } from '../../constants/servers.js';
|
import { BlitzServer } from '../../constants/servers.js';
|
||||||
import { Clan, ClanList } from '../../types/clanList.js';
|
import { Clan, ClanList } from '../../types/clanList.js';
|
||||||
import { wargamingApplicationId } from '../process/args.js';
|
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||||
import getWargamingResponse from './getWargamingResponse.js';
|
import getWargamingResponse from './getWargamingResponse.js';
|
||||||
|
|
||||||
export type ClanListWithServer = (Clan & {
|
export type ClanListWithServer = (Clan & {
|
||||||
@@ -15,7 +15,7 @@ export default async function listClansPanServer(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=${wargamingApplicationId}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -25,7 +25,7 @@ export default async function listClansPanServer(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${wargamingApplicationId}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
@@ -35,7 +35,7 @@ export default async function listClansPanServer(search: string, limit = 9) {
|
|||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
getWargamingResponse<ClanList>(
|
||||||
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${wargamingApplicationId}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
value &&
|
value &&
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
console.log(process.env);
|
export const DISCORD_TOKEN = process.env.DISCORD_TOKEN!;
|
||||||
|
export const WARGAMING_APPLICATION_ID = process.env.WARGAMING_APPLICATION_ID!;
|
||||||
|
|
||||||
export const discordToken = process.env.DISCORD_TOKEN!;
|
if (!DISCORD_TOKEN) {
|
||||||
export const wargamingApplicationId = process.env.WARGAMING_APPLICATION_ID!;
|
|
||||||
|
|
||||||
if (!discordToken) {
|
|
||||||
throw new Error('No Discord token provided');
|
throw new Error('No Discord token provided');
|
||||||
}
|
}
|
||||||
if (!wargamingApplicationId) {
|
if (!WARGAMING_APPLICATION_ID) {
|
||||||
throw new Error('No Wargaming application id provided}');
|
throw new Error('No Wargaming application id provided}');
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ import tankstats from '../commands/tankstats.js';
|
|||||||
import today from '../commands/today.js';
|
import today from '../commands/today.js';
|
||||||
import verify from '../commands/verify.js';
|
import verify from '../commands/verify.js';
|
||||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||||
import { discordToken } from '../core/process/args.js';
|
import { DISCORD_TOKEN } from '../core/process/args.js';
|
||||||
import getClientId from '../core/process/getClientId.js';
|
import getClientId from '../core/process/getClientId.js';
|
||||||
import isDev from '../core/process/isDev.js';
|
import isDev from '../core/process/isDev.js';
|
||||||
import { handleError } from './error.js';
|
import { handleError } from './error.js';
|
||||||
@@ -42,7 +42,7 @@ export interface CommandRegistry {
|
|||||||
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rest = new REST().setToken(discordToken);
|
const rest = new REST().setToken(DISCORD_TOKEN);
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
debug,
|
debug,
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { Client, GatewayIntentBits } from 'discord.js';
|
import { Client, GatewayIntentBits } from 'discord.js';
|
||||||
import { discordToken } from './core/process/args.js';
|
import { DISCORD_TOKEN } from './core/process/args.js';
|
||||||
import { registerErrorHandlers } from './events/error.js';
|
import { registerErrorHandlers } from './events/error.js';
|
||||||
import guildMemberAdd from './events/guildMemberAdd.js';
|
import guildMemberAdd from './events/guildMemberAdd.js';
|
||||||
import interactionCreate from './events/interactionCreate.js';
|
import interactionCreate from './events/interactionCreate.js';
|
||||||
@@ -13,4 +13,4 @@ export const client = new Client({
|
|||||||
.on('interactionCreate', interactionCreate);
|
.on('interactionCreate', interactionCreate);
|
||||||
|
|
||||||
registerErrorHandlers();
|
registerErrorHandlers();
|
||||||
client.login(discordToken);
|
client.login(DISCORD_TOKEN);
|
||||||
Reference in new issue
Block a user