mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a92cbd951 | ||
|
|
54c5faf929 | ||
|
|
d1d9e9e4d1 | ||
|
|
5ca64f839e | ||
|
|
4e7cd6f681 | ||
|
|
ba9f593716 | ||
|
|
9d3d74c7c5 | ||
|
|
aae26523ff | ||
|
|
338a2a14bf | ||
|
|
1a66cab435 | ||
|
|
3363c9ab58 | ||
|
|
10f64902aa | ||
|
|
25e1f4caa4 | ||
|
|
222fa89422 | ||
|
|
750e145f03 | ||
|
|
3bbbbfa402 | ||
|
|
f728751fa9 | ||
|
|
f5425d0e54 | ||
|
|
debaaccf4c | ||
|
|
a3e20501af | ||
|
|
c87a75f3fd | ||
|
|
55729c5eda | ||
|
|
06cbcc2339 | ||
|
|
1afe860e76 | ||
|
|
c0ac935652 | ||
|
|
7c76b0f5a5 | ||
|
|
42091c54b7 | ||
|
|
396b48d017 | ||
|
|
bb1c0c7625 | ||
|
|
1170676141 | ||
|
|
7baaaa9db9 | ||
|
|
c1ecef0179 | ||
|
|
032d98e6bd | ||
|
|
f4a90cd531 | ||
|
|
82f03583fe | ||
|
|
81c1a50052 | ||
|
|
c7207799e2 | ||
|
|
e0a719ee93 | ||
|
|
ee6d2e7d82 | ||
|
|
14710b5218 | ||
|
|
4b5e0d1c1c |
No files matched your search
@@ -1,34 +0,0 @@
|
|||||||
name: CD Asia Ratings Latest
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
host:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Use node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: "npm"
|
|
||||||
|
|
||||||
- name: Install Yarn
|
|
||||||
run: npm install --location=global yarn
|
|
||||||
|
|
||||||
- name: Use node_modules cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: "**/node_modules"
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn
|
|
||||||
|
|
||||||
- name: Generate leaderboard
|
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --latest
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
name: CD Asia Ratings Leaderboards
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 17 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
host:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Use node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: "npm"
|
|
||||||
|
|
||||||
- name: Install Yarn
|
|
||||||
run: npm install --location=global yarn
|
|
||||||
|
|
||||||
- name: Use node_modules cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: "**/node_modules"
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn
|
|
||||||
|
|
||||||
- name: Generate leaderboard
|
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia
|
|
||||||
@@ -2,7 +2,7 @@ name: CD Docs
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
name: CD Europe Ratings Latest
|
name: CD Ratings Asia
|
||||||
|
|
||||||
|
# latest: '0 0 * * *'
|
||||||
|
# asia midnight: '0 17 * * *'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * *"
|
- cron: '0 0 * * *'
|
||||||
|
- cron: '0 17 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
host:
|
host:
|
||||||
@@ -16,7 +20,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: "npm"
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install Yarn
|
- name: Install Yarn
|
||||||
run: npm install --location=global yarn
|
run: npm install --location=global yarn
|
||||||
@@ -24,11 +28,11 @@ jobs:
|
|||||||
- name: Use node_modules cache
|
- name: Use node_modules cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: "**/node_modules"
|
path: '**/node_modules'
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --latest
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
name: CD North America Ratings Latest
|
name: CD Ratings Europe
|
||||||
|
|
||||||
|
# latest: '0 0 * * *'
|
||||||
|
# eu midnight: '0 23 * * *'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 0 * * *'
|
||||||
|
- cron: '0 23 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
host:
|
host:
|
||||||
@@ -31,4 +35,4 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --latest
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
+9
-5
@@ -1,8 +1,12 @@
|
|||||||
name: CD Europe Ratings Leaderboards
|
name: CD Ratings North America
|
||||||
|
|
||||||
|
# latest: '0 0 * * *'
|
||||||
|
# na midnight: '0 5 * * *'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 23 * * *"
|
- cron: '0 0 * * *'
|
||||||
|
- cron: '0 5 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
host:
|
host:
|
||||||
@@ -16,7 +20,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: "npm"
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install Yarn
|
- name: Install Yarn
|
||||||
run: npm install --location=global yarn
|
run: npm install --location=global yarn
|
||||||
@@ -24,11 +28,11 @@ jobs:
|
|||||||
- name: Use node_modules cache
|
- name: Use node_modules cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: "**/node_modules"
|
path: '**/node_modules'
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: CI Build Bot
|
name: CI Build Bot
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: push
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: CI Build Docs
|
name: CI Build Docs
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: push
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: CI Build Website
|
name: CI Build Website
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: push
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
name: CD North America Ratings Leaderboards
|
name: CI Version
|
||||||
|
|
||||||
on:
|
on: push
|
||||||
schedule:
|
|
||||||
- cron: '0 5 * * *'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
host:
|
host:
|
||||||
@@ -31,4 +29,4 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na
|
run: yarn lint:version
|
||||||
Vendored
+3
@@ -13,9 +13,12 @@
|
|||||||
"Everytime",
|
"Everytime",
|
||||||
"fullstats",
|
"fullstats",
|
||||||
"fuzzysort",
|
"fuzzysort",
|
||||||
|
"immer",
|
||||||
"kranvagn",
|
"kranvagn",
|
||||||
|
"krieg",
|
||||||
"Leaderboard",
|
"Leaderboard",
|
||||||
"leaderboards",
|
"leaderboards",
|
||||||
|
"MURICA",
|
||||||
"Oopsy",
|
"Oopsy",
|
||||||
"outdir",
|
"outdir",
|
||||||
"outfile",
|
"outfile",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default defineConfig({
|
|||||||
themeConfig: {
|
themeConfig: {
|
||||||
nav: [
|
nav: [
|
||||||
{ text: 'Home', link: '/' },
|
{ text: 'Home', link: '/' },
|
||||||
{ text: 'Guide', link: '/guide/about' },
|
{ text: 'Guide', link: '/guide/introduction' },
|
||||||
],
|
],
|
||||||
|
|
||||||
sidebar: [
|
sidebar: [
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Blitzkrieg 1.15.1
|
||||||
|
|
||||||
|
'MURICA!
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- "Neighbor" is now spelled in the American way
|
||||||
|
- Updated documentation website with the latest information
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Fixed the guide link on the documentation website
|
||||||
|
|
||||||
|
## Technical features
|
||||||
|
|
||||||
|
- Added capability to fetch patiently while also parsing the JSON
|
||||||
|
|
||||||
|
## Technical changes
|
||||||
|
|
||||||
|
- Removed neighbor relative position caching
|
||||||
|
|
||||||
|
## Technical fixes
|
||||||
|
|
||||||
|
- `/ratings` now uses the non-caching APIs
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Blitzkrieg 1.15.2
|
||||||
|
|
||||||
|
Infinity reduced to a finite value.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Added a maximum value to the jump to position button
|
||||||
|
- Removed neighbor checking for the seeding player
|
||||||
|
- This fixes the jump to position button not loading at all
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Blitzkrieg 1.15.3
|
||||||
|
|
||||||
|
The bot now gets more expressive!
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- The bot can now have presence messages; examples:
|
||||||
|
- "Living in {number} servers"
|
||||||
|
- "Server {number} users"
|
||||||
|
- "Observing {number} channels"
|
||||||
|
- More will be added in the future! Give me some ideas
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Moved `/credits` to `/about creators`
|
||||||
|
- `/debug` command now ditches embeds and has better information to serve
|
||||||
|
|
||||||
|
## Technical Features
|
||||||
|
|
||||||
|
- Added a workflow and lint for package and changelog version miss match
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- Removed manual trigger for Asian latest ratings leaderboard archiver
|
||||||
|
- Leaderboard archiver now accepts an explicit target like `midnight` or `latest`
|
||||||
|
- Combined midnight and latest leaderboard archival workflow into one file
|
||||||
|
|
||||||
|
## Technical Fixed
|
||||||
|
|
||||||
|
- Reviewed all workflow triggers and updated them
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Blitzkrieg 1.15.4
|
||||||
|
|
||||||
|
Unlocking future potential
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- Moved the word "Ratings" to the front of the workflow name
|
||||||
|
- Renamed `blitzkrieg-db` to `blitzkrieg-assets`
|
||||||
|
- Moved the region folders from the root to `regions`
|
||||||
|
|
||||||
|
## Technical Fixes
|
||||||
|
|
||||||
|
- The ratings leaderboard archiver now correctly skips undefined players
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Blitzkrieg 1.15.5
|
||||||
|
|
||||||
|
Oops, this should've been in the last patch.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- User and channel cache is now guild cache exhaustive
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Creators
|
||||||
|
|
||||||
|
- TrèsAbhi `@tresabhi`
|
||||||
|
- Creator & main programmer; _I do it all!_
|
||||||
|
- Prince_NA `@prince_na`
|
||||||
|
- Advisor & tester
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Installing Blitzkrieg
|
|
||||||
|
|
||||||
It's easy as 1, 2, 3!
|
|
||||||
|
|
||||||
## Step 1
|
|
||||||
|
|
||||||
Join a server that already has Blitzkrieg or [join our official Discord server](https://discord.gg/nDt7AjGJQH).
|
|
||||||
|
|
||||||
## Step 2
|
|
||||||
|
|
||||||
View the bot's profile and click "Add to Server".
|
|
||||||
|
|
||||||
<video src="https://i.imgur.com/Zq0P3m2.mp4" autoplay loop muted width=320 title="how to install"></video>
|
|
||||||
|
|
||||||
## Step 3
|
|
||||||
|
|
||||||
Review the permissions the bot is asking for and add it to your server!
|
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
Blitzkrieg is a multipurpose bot for anything and everything World of Tanks Blitz.
|
🎉 Services for everything and anything World of Tanks Blitz
|
||||||
|
|
||||||
|
## Bot
|
||||||
|
|
||||||
|
Blitzkrieg is available as a Discord bot and can be [installed very easily](/guide/invite).
|
||||||
|
|
||||||
- Track statistics
|
- Track statistics
|
||||||
- Find inactive players in a clan
|
- Find inactive players in a clan
|
||||||
@@ -8,3 +12,11 @@ Blitzkrieg is a multipurpose bot for anything and everything World of Tanks Blit
|
|||||||
- Create embeds for streams
|
- Create embeds for streams
|
||||||
- Track a player/tanks statistical evolution
|
- Track a player/tanks statistical evolution
|
||||||
- ...and a variety of other similar things
|
- ...and a variety of other similar things
|
||||||
|
|
||||||
|
## Website
|
||||||
|
|
||||||
|
Provides a bunch of very helpful tools; https://blitz-krieg.vercel.app/
|
||||||
|
|
||||||
|
- Session tracker
|
||||||
|
- Ratings leaderboard
|
||||||
|
- Way more to come
|
||||||
+2
-2
@@ -12,10 +12,10 @@ hero:
|
|||||||
actions:
|
actions:
|
||||||
- theme: brand
|
- theme: brand
|
||||||
text: Add to Discord Server
|
text: Add to Discord Server
|
||||||
link: guide/install
|
link: /guide/invite
|
||||||
- theme: alt
|
- theme: alt
|
||||||
text: Guide
|
text: Guide
|
||||||
link: /guide/about
|
link: /guide/introduction
|
||||||
|
|
||||||
features:
|
features:
|
||||||
- title: Clean and Efficient UI
|
- title: Clean and Efficient UI
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "blitzkrieg",
|
"name": "blitzkrieg",
|
||||||
"version": "1.15.0",
|
"version": "1.15.5",
|
||||||
"description": "🎉 Tools for everything World of Tanks Blitz",
|
"description": "🎉 Tools for everything World of Tanks Blitz",
|
||||||
"main": "src/server.ts",
|
"main": "src/server.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"lint": "npx tsc",
|
"lint": "npx tsc",
|
||||||
"lint:website": "next lint",
|
"lint:website": "next lint",
|
||||||
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
||||||
|
"lint:version": "vite-node --script scripts/checkVersionMissMatch",
|
||||||
"knip": "knip",
|
"knip": "knip",
|
||||||
"update": "yarn upgrade --latest"
|
"update": "yarn upgrade --latest"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
RatingsNeighbors,
|
RatingsNeighbors,
|
||||||
RatingsPlayer,
|
RatingsPlayer,
|
||||||
} from '../src/commands/ratings';
|
} from '../src/commands/ratings';
|
||||||
import { patientFetch } from '../src/core/blitzkrieg/patientFetch';
|
import { patientFetchJSON } from '../src/core/blitzkrieg/patientFetchJSON';
|
||||||
import commitMultipleFiles from './commitMultipleFiles.js';
|
import commitMultipleFiles from './commitMultipleFiles.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -23,17 +23,18 @@ export type BlitzkriegRatingsLeaderboardEntry = { id: number; score: number };
|
|||||||
export type BlitzkriegRatingsLeaderboard = BlitzkriegRatingsLeaderboardEntry[];
|
export type BlitzkriegRatingsLeaderboard = BlitzkriegRatingsLeaderboardEntry[];
|
||||||
|
|
||||||
const publish = argv.includes('--publish');
|
const publish = argv.includes('--publish');
|
||||||
const latest = argv.includes('--latest');
|
const target = argv
|
||||||
|
.find((arg) => arg.startsWith('--target='))
|
||||||
|
?.split('=')[1] as 'midnight' | 'latest' | undefined;
|
||||||
const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1];
|
const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1];
|
||||||
|
|
||||||
|
if (!target) throw new Error('Target parameter not specified');
|
||||||
if (!server) throw new Error('Region parameter not specified');
|
if (!server) throw new Error('Region parameter not specified');
|
||||||
|
|
||||||
const NEIGHBORS = 1024;
|
const NEIGHBORS = 2 ** 8;
|
||||||
const PLAYERS = await patientFetch(
|
const PLAYERS = await patientFetchJSON<RatingsInfo>(
|
||||||
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||||
)
|
).then((data) => (data.detail === undefined ? data.count : undefined));
|
||||||
.then((response) => response.json() as Promise<RatingsInfo>)
|
|
||||||
.then((data) => (data.detail === undefined ? data.count : undefined));
|
|
||||||
|
|
||||||
if (PLAYERS === undefined) {
|
if (PLAYERS === undefined) {
|
||||||
throw new Error('No current ratings season running');
|
throw new Error('No current ratings season running');
|
||||||
@@ -44,9 +45,9 @@ const leaderboard: BlitzkriegRatingsLeaderboard = [];
|
|||||||
let registered = 0;
|
let registered = 0;
|
||||||
|
|
||||||
async function branchFromPlayer(id: number) {
|
async function branchFromPlayer(id: number) {
|
||||||
const { neighbors } = await patientFetch(
|
const { neighbors } = await patientFetchJSON<RatingsNeighbors>(
|
||||||
`https://${server}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${NEIGHBORS}`,
|
`https://${server}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${NEIGHBORS}`,
|
||||||
).then((response) => response.json() as Promise<RatingsNeighbors>);
|
);
|
||||||
|
|
||||||
const firstPlayer = neighbors[0];
|
const firstPlayer = neighbors[0];
|
||||||
const lastPlayer = neighbors[neighbors.length - 1];
|
const lastPlayer = neighbors[neighbors.length - 1];
|
||||||
@@ -75,9 +76,9 @@ async function branchFromPlayer(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function branchFromLeague(id: number) {
|
async function branchFromLeague(id: number) {
|
||||||
const { result } = await patientFetch(
|
const { result } = await patientFetchJSON<{ result: RatingsPlayer[] }>(
|
||||||
`https://${server}.wotblitz.com/en/api/rating-leaderboards/league/${id}/top/`,
|
`https://${server}.wotblitz.com/en/api/rating-leaderboards/league/${id}/top/`,
|
||||||
).then((response) => response.json() as Promise<{ result: RatingsPlayer[] }>);
|
);
|
||||||
|
|
||||||
const firstPlayer = result[0];
|
const firstPlayer = result[0];
|
||||||
const lastPlayer = result[result.length - 1];
|
const lastPlayer = result[result.length - 1];
|
||||||
@@ -100,7 +101,10 @@ await Promise.all([
|
|||||||
console.log('Converting to an array...');
|
console.log('Converting to an array...');
|
||||||
for (let index = 0; index < PLAYERS; index++) {
|
for (let index = 0; index < PLAYERS; index++) {
|
||||||
const listing = players[index + 1];
|
const listing = players[index + 1];
|
||||||
if (!listing) console.warn(`Position ${index + 1} had no player`);
|
if (!listing) {
|
||||||
|
console.warn(`Position ${index + 1} had no player`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
leaderboard[index] = {
|
leaderboard[index] = {
|
||||||
id: listing.spa_id,
|
id: listing.spa_id,
|
||||||
@@ -112,26 +116,19 @@ const leaderboardJSON = JSON.stringify(leaderboard);
|
|||||||
|
|
||||||
if (publish) {
|
if (publish) {
|
||||||
const octokit = new Octokit({ auth: env.GH_TOKEN });
|
const octokit = new Octokit({ auth: env.GH_TOKEN });
|
||||||
|
const info = await patientFetchJSON<RatingsInfo & { detail: undefined }>(
|
||||||
const info = await patientFetch(
|
|
||||||
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||||
).then(
|
|
||||||
(response) =>
|
|
||||||
response.json() as Promise<RatingsInfo & { detail: undefined }>,
|
|
||||||
);
|
);
|
||||||
const normalizedServer = server === 'na' ? 'com' : server;
|
const normalizedServer = server === 'na' ? 'com' : server;
|
||||||
|
const infoPath = `regions/${normalizedServer}/ratings/${info.current_season}/info.json`;
|
||||||
const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`;
|
const leaderboardPath = `regions/${normalizedServer}/ratings/${info.current_season}/${target}.json`;
|
||||||
const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${
|
|
||||||
latest ? 'latest' : 'midnight'
|
|
||||||
}.json`;
|
|
||||||
const infoJSON = JSON.stringify(info);
|
const infoJSON = JSON.stringify(info);
|
||||||
|
|
||||||
console.log(`Publishing to season ${info.current_season}...`);
|
console.log(`Publishing to season ${info.current_season}...`);
|
||||||
commitMultipleFiles(
|
commitMultipleFiles(
|
||||||
octokit,
|
octokit,
|
||||||
'tresabhi',
|
'tresabhi',
|
||||||
'blitzkrieg-db',
|
'blitzkrieg-assets',
|
||||||
'main',
|
'main',
|
||||||
new Date().toString(),
|
new Date().toString(),
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { readdir } from 'fs/promises';
|
||||||
|
import packageJSON from '../package.json';
|
||||||
|
|
||||||
|
const { version } = packageJSON;
|
||||||
|
const changelogs = await readdir('docs/changelogs');
|
||||||
|
const hasVersion = changelogs.includes(`${version}.md`);
|
||||||
|
|
||||||
|
if (hasVersion) {
|
||||||
|
console.log(`Version ${version} found in changelogs`);
|
||||||
|
} else {
|
||||||
|
throw new Error(`Version ${version} not found in changelogs`);
|
||||||
|
}
|
||||||
@@ -137,15 +137,12 @@ export default function Page() {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
range(0, 5).map(async (league: number) => {
|
range(0, 5).map(async (league: number) => {
|
||||||
const data = await getRatingsLeague(region, league);
|
const data = await getRatingsLeague(region, league);
|
||||||
leaguePositionCache.current[region][league] =
|
leaguePositionCache.current[region][league] = data[0].number - 1;
|
||||||
data.result[0].number - 1;
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
)
|
).flat();
|
||||||
.map(({ result }) => result)
|
|
||||||
.flat();
|
|
||||||
|
|
||||||
useLeaderboardCache.setState(
|
useLeaderboardCache.setState(
|
||||||
produce((draft: LeaderboardCache) => {
|
produce((draft: LeaderboardCache) => {
|
||||||
@@ -302,19 +299,12 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const seedingPlayerNeighborEntry = Object.entries(
|
|
||||||
leaderboard[region][season],
|
|
||||||
).find(([, player]) => id === player);
|
|
||||||
|
|
||||||
if (seedingPlayerNeighborEntry === undefined) return null;
|
|
||||||
|
|
||||||
const seedingPlayerPosition = parseInt(seedingPlayerNeighborEntry[0]);
|
|
||||||
const { neighbors } = await getRatingsNeighbors(region, id, size, true);
|
const { neighbors } = await getRatingsNeighbors(region, id, size, true);
|
||||||
|
|
||||||
useLeaderboardCache.setState(
|
useLeaderboardCache.setState(
|
||||||
produce((draft: LeaderboardCache) => {
|
produce((draft: LeaderboardCache) => {
|
||||||
neighbors.forEach((neighbor, neighborIndex) => {
|
neighbors.forEach((neighbor, neighborIndex) => {
|
||||||
const position = neighborIndex - radius + seedingPlayerPosition;
|
const position = neighbor.number - 1;
|
||||||
|
|
||||||
if (!(position in draft[region][season])) {
|
if (!(position in draft[region][season])) {
|
||||||
draft[region][season][position] = neighbor.spa_id;
|
draft[region][season][position] = neighbor.spa_id;
|
||||||
@@ -349,9 +339,9 @@ export default function Page() {
|
|||||||
async function jumpToPosition(position: number) {
|
async function jumpToPosition(position: number) {
|
||||||
if (!ratingsInfo || ratingsInfo?.detail) return;
|
if (!ratingsInfo || ratingsInfo?.detail) return;
|
||||||
|
|
||||||
const targetPosition = Math.max(
|
const targetPosition = Math.min(
|
||||||
0,
|
ratingsInfo.count - 1,
|
||||||
Math.min(position, ratingsInfo.count - 1),
|
Math.max(0, Math.min(position, ratingsInfo.count - 1)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (season === 0) {
|
if (season === 0) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const DOCS = {
|
|||||||
introduction: 'guide/introduction',
|
introduction: 'guide/introduction',
|
||||||
invite: 'guide/invite',
|
invite: 'guide/invite',
|
||||||
timezones: 'guide/timezones',
|
timezones: 'guide/timezones',
|
||||||
|
creators: 'guide/creators',
|
||||||
};
|
};
|
||||||
const DOC_DESCRIPTIONS: Record<keyof typeof DOCS, string> = {
|
const DOC_DESCRIPTIONS: Record<keyof typeof DOCS, string> = {
|
||||||
permissions: 'The permissions needed for the bot to function',
|
permissions: 'The permissions needed for the bot to function',
|
||||||
@@ -18,6 +19,7 @@ const DOC_DESCRIPTIONS: Record<keyof typeof DOCS, string> = {
|
|||||||
introduction: 'About the bot',
|
introduction: 'About the bot',
|
||||||
invite: 'How to invite the bot',
|
invite: 'How to invite the bot',
|
||||||
timezones: 'How Blitzkrieg infers and uses your timezone',
|
timezones: 'How Blitzkrieg infers and uses your timezone',
|
||||||
|
creators: 'Who created the bot',
|
||||||
};
|
};
|
||||||
|
|
||||||
function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) {
|
function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js';
|
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
|
||||||
|
|
||||||
export const creditsCommand: CommandRegistry = {
|
|
||||||
inProduction: true,
|
|
||||||
inPublic: true,
|
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
|
||||||
.setName('credits')
|
|
||||||
.setDescription('Me and the people who made this bot'),
|
|
||||||
|
|
||||||
async handler() {
|
|
||||||
return new AttachmentBuilder('https://i.imgur.com/ZF5ch33.png');
|
|
||||||
},
|
|
||||||
};
|
|
||||||
+15
-23
@@ -1,11 +1,6 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||||
import getClientId from '../core/blitzkrieg/getClientId';
|
|
||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
|
||||||
import { tankopedia } from '../core/blitzstars/tankopedia';
|
|
||||||
import { client } from '../core/discord/client';
|
import { client } from '../core/discord/client';
|
||||||
import embedInfo from '../core/discord/embedInfo';
|
|
||||||
import markdownTable from '../core/discord/markdownTable';
|
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
const executionStart = new Date().getTime();
|
const executionStart = new Date().getTime();
|
||||||
@@ -21,24 +16,21 @@ export const debugCommand: CommandRegistry = {
|
|||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const currentTime = new Date().getTime();
|
const currentTime = new Date().getTime();
|
||||||
const uptime = currentTime - executionStart;
|
const uptime = currentTime - executionStart;
|
||||||
|
const list = [
|
||||||
|
['Version', packageJSON.version],
|
||||||
|
['Shard', client.shard?.ids[0] ?? 'default'],
|
||||||
|
[
|
||||||
|
'Uptime',
|
||||||
|
`${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor(
|
||||||
|
(uptime / 1000 / 60) % 60,
|
||||||
|
)}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor(
|
||||||
|
uptime % 1000,
|
||||||
|
)}ms`,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
.map(([key, value]) => `- ${key}: ${value}`)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
return embedInfo(
|
return `# Debug\n\n${list}`;
|
||||||
`${client.user?.username} debug information`,
|
|
||||||
markdownTable([
|
|
||||||
['Version', packageJSON.version],
|
|
||||||
['Client ID', getClientId()],
|
|
||||||
['Tag', interaction.client.user.tag],
|
|
||||||
[
|
|
||||||
'Uptime',
|
|
||||||
`${Math.floor(uptime / 1000 / 60 / 60 / 24)}d ${Math.floor(
|
|
||||||
(uptime / 1000 / 60 / 60) % 24,
|
|
||||||
)}h ${Math.floor((uptime / 1000 / 60) % 60)}m ${Math.floor(
|
|
||||||
(uptime / 1000) % 60,
|
|
||||||
)}s ${Math.floor(uptime % 1000)}ms`,
|
|
||||||
],
|
|
||||||
['Tankopedia cached', `${(await tankopedia) !== undefined}`],
|
|
||||||
['Tank averages cached', `${(await tankAverages) !== undefined}`],
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
+25
-31
@@ -15,6 +15,8 @@ import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
|||||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
||||||
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
||||||
|
import { getRatingsLeague } from '../core/blitz/getRatingsLeague';
|
||||||
|
import { getRatingsNeighbors } from '../core/blitz/getRatingsNeighbors';
|
||||||
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
||||||
import { getArchivedLatestSeasonNumber } from '../core/blitzkrieg/getArchivedLatestSeasonNumber';
|
import { getArchivedLatestSeasonNumber } from '../core/blitzkrieg/getArchivedLatestSeasonNumber';
|
||||||
import getArchivedRatingsInfo from '../core/blitzkrieg/getArchivedRatingsInfo';
|
import getArchivedRatingsInfo from '../core/blitzkrieg/getArchivedRatingsInfo';
|
||||||
@@ -123,14 +125,14 @@ function addSubcommands(
|
|||||||
.addSubcommand((option) =>
|
.addSubcommand((option) =>
|
||||||
addOptions(
|
addOptions(
|
||||||
option
|
option
|
||||||
.setName('neighbours')
|
.setName('neighbors')
|
||||||
.setDescription('Your position and neighbours'),
|
.setDescription('Your position and neighbors'),
|
||||||
)
|
)
|
||||||
.addStringOption(addUsernameChoices)
|
.addStringOption(addUsernameChoices)
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('limit')
|
.setName('limit')
|
||||||
.setDescription('How many neighbours to display (default: 10)')
|
.setDescription('How many neighbors to display (default: 10)')
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setMinValue(5)
|
.setMinValue(5)
|
||||||
.setMaxValue(30),
|
.setMaxValue(30),
|
||||||
@@ -228,7 +230,7 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
|||||||
| 'current';
|
| 'current';
|
||||||
const subcommand = interaction.options.getSubcommand(true) as
|
const subcommand = interaction.options.getSubcommand(true) as
|
||||||
| 'league'
|
| 'league'
|
||||||
| 'neighbours';
|
| 'neighbors';
|
||||||
const limit = interaction.options.getInteger('limit') ?? 10;
|
const limit = interaction.options.getInteger('limit') ?? 10;
|
||||||
const seasonOption = interaction.options.getString('season');
|
const seasonOption = interaction.options.getString('season');
|
||||||
const season = seasonOption ? parseInt(seasonOption) : undefined;
|
const season = seasonOption ? parseInt(seasonOption) : undefined;
|
||||||
@@ -257,11 +259,8 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
|||||||
const regionSubdomain = regionToRegionSubdomain(region);
|
const regionSubdomain = regionToRegionSubdomain(region);
|
||||||
const result =
|
const result =
|
||||||
subcommandGroup === 'current'
|
subcommandGroup === 'current'
|
||||||
? await fetch(
|
? await getRatingsLeague(region, leagueIndex).then(
|
||||||
`https://${regionSubdomain}.wotblitz.com/en/api/rating-leaderboards/league/${leagueIndex}/top/`,
|
async (result) =>
|
||||||
)
|
|
||||||
.then((response) => response.json() as Promise<LeagueTop>)
|
|
||||||
.then(async ({ result }) =>
|
|
||||||
result.slice(0, limit).map(
|
result.slice(0, limit).map(
|
||||||
(player) =>
|
(player) =>
|
||||||
({
|
({
|
||||||
@@ -272,7 +271,7 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
|||||||
nickname: player.nickname,
|
nickname: player.nickname,
|
||||||
}) satisfies SimplifiedPlayer,
|
}) satisfies SimplifiedPlayer,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: await getArchivedRatingsLeaderboard(region, season!).then(
|
: await getArchivedRatingsLeaderboard(region, season!).then(
|
||||||
async (players) => {
|
async (players) => {
|
||||||
const firstPlayerIndex =
|
const firstPlayerIndex =
|
||||||
@@ -338,29 +337,24 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
|||||||
|
|
||||||
const accountInfo = await getAccountInfo(region, id);
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
|
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
|
||||||
const regionSubdomain = regionToRegionSubdomain(region);
|
|
||||||
const neighbors =
|
const neighbors =
|
||||||
subcommandGroup === 'current'
|
subcommandGroup === 'current'
|
||||||
? await fetch(
|
? await getRatingsNeighbors(
|
||||||
`https://${regionSubdomain}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${Math.round(
|
region,
|
||||||
limit / 2,
|
id,
|
||||||
)}`,
|
Math.round(limit / 2),
|
||||||
|
).then((players) =>
|
||||||
|
players.neighbors.map(
|
||||||
|
(player) =>
|
||||||
|
({
|
||||||
|
id: player.spa_id,
|
||||||
|
position: player.number,
|
||||||
|
score: player.score,
|
||||||
|
clan: player.clan_tag,
|
||||||
|
nickname: player.nickname,
|
||||||
|
}) satisfies SimplifiedPlayer,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.then(
|
|
||||||
(response) => response.json() as Promise<RatingsNeighbors>,
|
|
||||||
)
|
|
||||||
.then((players) =>
|
|
||||||
players.neighbors.map(
|
|
||||||
(player) =>
|
|
||||||
({
|
|
||||||
id: player.spa_id,
|
|
||||||
position: player.number,
|
|
||||||
score: player.score,
|
|
||||||
clan: player.clan_tag,
|
|
||||||
nickname: player.nickname,
|
|
||||||
}) satisfies SimplifiedPlayer,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: await getArchivedRatingsLeaderboard(region, season!).then(
|
: await getArchivedRatingsLeaderboard(region, season!).then(
|
||||||
async (players) => {
|
async (players) => {
|
||||||
const playerIndex = players.findIndex(
|
const playerIndex = players.findIndex(
|
||||||
@@ -414,7 +408,7 @@ export const ratingsCommand = new Promise<CommandRegistryRaw>(
|
|||||||
titleName = neighbors
|
titleName = neighbors
|
||||||
? accountInfo.nickname
|
? accountInfo.nickname
|
||||||
: `No Ongoing Season - ${REGION_NAMES_SHORT[region]}`;
|
: `No Ongoing Season - ${REGION_NAMES_SHORT[region]}`;
|
||||||
titleDescription = 'Ratings neighbours';
|
titleDescription = 'Ratings neighbors';
|
||||||
playersBefore = neighbors ? neighbors[0].position - 1 : 0;
|
playersBefore = neighbors ? neighbors[0].position - 1 : 0;
|
||||||
playersAfter =
|
playersAfter =
|
||||||
regionRatingsInfo.count - neighbors[neighbors.length - 1].position;
|
regionRatingsInfo.count - neighbors[neighbors.length - 1].position;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { LeagueTop } from '../../commands/ratings';
|
import { LeagueTop, RatingsPlayer } from '../../commands/ratings';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { context } from '../blitzkrieg/context';
|
import { context } from '../blitzkrieg/context';
|
||||||
import { patientFetch } from '../blitzkrieg/patientFetch';
|
import { patientFetch } from '../blitzkrieg/patientFetch';
|
||||||
@@ -9,7 +9,10 @@ export async function getRatingsLeague(
|
|||||||
league: number,
|
league: number,
|
||||||
usePatientFetcher = false,
|
usePatientFetcher = false,
|
||||||
) {
|
) {
|
||||||
const fetcher = usePatientFetcher ? patientFetch : fetch;
|
const fetcher = (url: string) =>
|
||||||
|
usePatientFetcher
|
||||||
|
? patientFetch(url, undefined, { cache: 'no-store' })
|
||||||
|
: fetch(url, { cache: 'no-store' });
|
||||||
const response = await fetcher(
|
const response = await fetcher(
|
||||||
context === 'website'
|
context === 'website'
|
||||||
? `/api/${region}/ratings/current/league/${league}`
|
? `/api/${region}/ratings/current/league/${league}`
|
||||||
@@ -17,7 +20,9 @@ export async function getRatingsLeague(
|
|||||||
region,
|
region,
|
||||||
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
||||||
);
|
);
|
||||||
const json = (await response.json()) as LeagueTop;
|
const json = await response.json();
|
||||||
|
|
||||||
return json;
|
return context === 'website'
|
||||||
|
? (json as RatingsPlayer[])
|
||||||
|
: (json as LeagueTop).result;
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,10 @@ export async function getRatingsNeighbors(
|
|||||||
count: number,
|
count: number,
|
||||||
usePatientFetcher = false,
|
usePatientFetcher = false,
|
||||||
) {
|
) {
|
||||||
const fetcher = usePatientFetcher
|
const fetcher = (url: string) =>
|
||||||
? patientFetch
|
usePatientFetcher
|
||||||
: (url: string) => fetch(url, { cache: 'no-store' });
|
? patientFetch(url, undefined, { cache: 'no-store' })
|
||||||
|
: fetch(url, { cache: 'no-store' });
|
||||||
const response = await fetcher(
|
const response = await fetcher(
|
||||||
withCORSProxy(
|
withCORSProxy(
|
||||||
`https://${regionToRegionSubdomain(
|
`https://${regionToRegionSubdomain(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export async function getArchivedLatestSeasonNumber() {
|
|||||||
if (ratingsInfo.detail) {
|
if (ratingsInfo.detail) {
|
||||||
const comURL = (
|
const comURL = (
|
||||||
(await fetch(
|
(await fetch(
|
||||||
'https://api.github.com/repos/tresabhi/blitzkrieg-db/git/trees/main',
|
'https://api.github.com/repos/tresabhi/blitzkrieg-assets/git/trees/main',
|
||||||
).then((response) => response.json())) as {
|
).then((response) => response.json())) as {
|
||||||
tree: { path: string; url: string }[];
|
tree: { path: string; url: string }[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default async function getArchivedRatingsInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/info.json`,
|
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/info.json`,
|
||||||
);
|
);
|
||||||
const jsonContent = (await response.json()) as RatingsInfo & {
|
const jsonContent = (await response.json()) as RatingsInfo & {
|
||||||
detail: undefined;
|
detail: undefined;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export async function getArchivedRatingsLeaderboard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/latest.json`,
|
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/latest.json`,
|
||||||
);
|
);
|
||||||
const json = (await response.json()) as BlitzkriegRatingsLeaderboard;
|
const json = (await response.json()) as BlitzkriegRatingsLeaderboard;
|
||||||
LEADERBOARD_CACHE[region][season] = json;
|
LEADERBOARD_CACHE[region][season] = json;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
|
|
||||||
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' };
|
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-assets' };
|
||||||
|
|
||||||
const MIDNIGHT_LEADERBOARD_CACHE: Record<
|
const MIDNIGHT_LEADERBOARD_CACHE: Record<
|
||||||
Region,
|
Region,
|
||||||
@@ -22,7 +22,7 @@ export default async function getArchivedRatingsMidnightLeaderboard(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/midnight.json`,
|
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/midnight.json`,
|
||||||
);
|
);
|
||||||
const json = (await response.json()) as BlitzkriegRatingsLeaderboard;
|
const json = (await response.json()) as BlitzkriegRatingsLeaderboard;
|
||||||
MIDNIGHT_LEADERBOARD_CACHE[region][season] = json;
|
MIDNIGHT_LEADERBOARD_CACHE[region][season] = json;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export async function patientFetchJSON<Type extends object>(
|
||||||
|
url: string,
|
||||||
|
timeout = 1000,
|
||||||
|
options?: Partial<{ cache: 'no-store' }>,
|
||||||
|
) {
|
||||||
|
let patientJSON: Type;
|
||||||
|
|
||||||
|
while (patientJSON! === undefined) {
|
||||||
|
try {
|
||||||
|
patientJSON = (await fetch(url, options).then((response) =>
|
||||||
|
response.json(),
|
||||||
|
)) as Type;
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(
|
||||||
|
`Failed to fetch ${url} as JSON; retrying in ${timeout}ms...`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, timeout));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return patientJSON;
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Client, GatewayIntentBits } from 'discord.js';
|
import { Client, GatewayIntentBits } from 'discord.js';
|
||||||
import guildMemberAdd from '../../events/guildMemberAdd';
|
import guildMemberAdd from '../../events/guildMemberAdd';
|
||||||
import interactionCreate from '../../events/interactionCreate';
|
import interactionCreate from '../../events/interactionCreate';
|
||||||
|
import ready from '../../events/ready';
|
||||||
|
|
||||||
export const client = new Client({
|
export const client = new Client({
|
||||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
||||||
})
|
})
|
||||||
// .on('ready', ready)
|
.on('ready', ready)
|
||||||
.on('guildMemberAdd', guildMemberAdd)
|
.on('guildMemberAdd', guildMemberAdd)
|
||||||
.on('interactionCreate', interactionCreate);
|
.on('interactionCreate', interactionCreate);
|
||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
import discord from '../../../discord.json' assert { type: 'json' };
|
import discord from '../../../discord.json' assert { type: 'json' };
|
||||||
import { aboutCommand } from '../../commands/about';
|
import { aboutCommand } from '../../commands/about';
|
||||||
import { breakdownCommand } from '../../commands/breakdown';
|
import { breakdownCommand } from '../../commands/breakdown';
|
||||||
import { creditsCommand } from '../../commands/credits';
|
|
||||||
import { debugCommand } from '../../commands/debug';
|
import { debugCommand } from '../../commands/debug';
|
||||||
import { eligibleCommand } from '../../commands/eligible';
|
import { eligibleCommand } from '../../commands/eligible';
|
||||||
import { evolutionCommand } from '../../commands/evolution';
|
import { evolutionCommand } from '../../commands/evolution';
|
||||||
@@ -102,7 +101,6 @@ export const COMMANDS_RAW: CommandRegistry[] = [
|
|||||||
evolutionCommand,
|
evolutionCommand,
|
||||||
statsCommand,
|
statsCommand,
|
||||||
ratingsCommand,
|
ratingsCommand,
|
||||||
creditsCommand,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const commands = Promise.all(COMMANDS_RAW).then((rawCommands) =>
|
export const commands = Promise.all(COMMANDS_RAW).then((rawCommands) =>
|
||||||
|
|||||||
+26
-2
@@ -1,5 +1,29 @@
|
|||||||
import { Client } from 'discord.js';
|
import { ActivityType, Client } from 'discord.js';
|
||||||
|
|
||||||
export default function ready(client: Client<true>) {
|
export default function ready(client: Client<true>) {
|
||||||
console.log(`🟢 Launched bot ${client.shard?.ids[0]}`);
|
console.log(`🟢 Launched bot ${client.shard?.ids[0] ?? 'default'}`);
|
||||||
|
|
||||||
|
const activities: (() => string)[] = [
|
||||||
|
() => `Living in ${client.guilds.cache.size.toLocaleString()} servers`,
|
||||||
|
() =>
|
||||||
|
`Serving ${client.guilds.cache
|
||||||
|
.reduce((accumulator, guild) => accumulator + guild.memberCount, 0)
|
||||||
|
.toLocaleString()} users`,
|
||||||
|
() =>
|
||||||
|
`Observing ${client.guilds.cache
|
||||||
|
.reduce(
|
||||||
|
(accumulator, guild) => accumulator + guild.channels.cache.size,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
.toLocaleString()} channels`,
|
||||||
|
];
|
||||||
|
|
||||||
|
client.user.setPresence({
|
||||||
|
activities: [
|
||||||
|
{
|
||||||
|
type: ActivityType.Custom,
|
||||||
|
name: activities[Math.floor(Math.random() * activities.length)](),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user