mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c4cd664b | ||
|
|
f907c79d68 | ||
|
|
ae3d0a08cd | ||
|
|
fb66027de0 | ||
|
|
423ad4e433 | ||
|
|
cf291c89a2 | ||
|
|
604e356736 | ||
|
|
00b721f34f | ||
|
|
95b105cb65 | ||
|
|
433ffba1e3 | ||
|
|
423a8b8088 | ||
|
|
d2d575bd72 | ||
|
|
2958124499 | ||
|
|
5addc55dd0 | ||
|
|
c78e58106a | ||
|
|
798f063712 | ||
|
|
ff99487b13 | ||
|
|
0c58515fd0 | ||
|
|
c39a59d321 | ||
|
|
3167e311c2 | ||
|
|
7b17d3f96e | ||
|
|
ac87a9d919 | ||
|
|
25ea608d81 | ||
|
|
ebe1fb891b | ||
|
|
931257d18d | ||
|
|
ae66fc92ef | ||
|
|
fc4390d22f | ||
|
|
4c2b0253de | ||
|
|
e34a6c6e4b | ||
|
|
90d4b76b31 | ||
|
|
3fd90588a3 | ||
|
|
e81c0cbc1e | ||
|
|
4c9715988d | ||
|
|
c2d2d076f0 | ||
|
|
d1d8aad6c7 | ||
|
|
dd39563d6d | ||
|
|
64fd15c0a5 | ||
|
|
5fb36352d2 | ||
|
|
8bf8030157 | ||
|
|
da950ad42f | ||
|
|
f8f95af215 | ||
|
|
a0ba60a3fb | ||
|
|
ab5061ba99 | ||
|
|
01ed20941d | ||
|
|
169588a211 | ||
|
|
c7821d03d2 | ||
|
|
9dc48c9125 | ||
|
|
a67d1700fc | ||
|
|
c221c06511 | ||
|
|
abcb75f06e | ||
|
|
7dd3913ae8 | ||
|
|
f2ae698438 | ||
|
|
0f46f333b5 | ||
|
|
79343438f0 | ||
|
|
8dd0ca9d10 | ||
|
|
aa0069a0a3 | ||
|
|
8882c28267 | ||
|
|
24cf2c2cd9 | ||
|
|
8570559588 | ||
|
|
d8f53bff9f | ||
|
|
58f5b894f9 |
No files matched your search
@@ -0,0 +1,64 @@
|
||||
name: CD Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- name: Get code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Use node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
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: Build docs
|
||||
run: yarn build:docs
|
||||
|
||||
- name: Configure pages
|
||||
uses: actions/configure-pages@v2
|
||||
|
||||
- name: Upload pages artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: docs/.vitepress/dist
|
||||
|
||||
- name: Deploy
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
|
||||
- name: Archive build
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dist
|
||||
path: docs/.vitepress/dist
|
||||
@@ -3,9 +3,6 @@ name: Host
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */5 * * *'
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
@@ -34,5 +31,5 @@ jobs:
|
||||
curl -L -o dist.zip $DOWNLOAD_URL
|
||||
unzip dist.zip
|
||||
|
||||
- name: Run index.cjs
|
||||
run: NODE_ENV=production DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ secrets.WARGAMING_APPLICATION_ID }} node --enable-source-maps --trace-warnings index.cjs
|
||||
- name: Run bot
|
||||
run: NODE_ENV=production DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} WARGAMING_APPLICATION_ID=${{ secrets.WARGAMING_APPLICATION_ID }} node --enable-source-maps --trace-warnings bot.cjs
|
||||
@@ -9,3 +9,5 @@ yarn-error.log
|
||||
dist.zip
|
||||
commands.txt
|
||||
/test.*
|
||||
/docs/.vitepress/dist
|
||||
/docs/.vitepress/cache
|
||||
Vendored
+5
@@ -6,6 +6,7 @@
|
||||
"blitzstars",
|
||||
"cleandist",
|
||||
"customperiod",
|
||||
"Everytime",
|
||||
"fuzzysort",
|
||||
"kranvagn",
|
||||
"outfile",
|
||||
@@ -13,18 +14,22 @@
|
||||
"playerachievements",
|
||||
"playerinfo",
|
||||
"Resvg",
|
||||
"roboto",
|
||||
"searchclans",
|
||||
"searchplayers",
|
||||
"searchtanks",
|
||||
"SKLLD",
|
||||
"Smri",
|
||||
"startcase",
|
||||
"statsfull",
|
||||
"strvk",
|
||||
"tankaverages",
|
||||
"tankopedia",
|
||||
"tankstats",
|
||||
"Unicum",
|
||||
"Unregistering",
|
||||
"vickers",
|
||||
"vitepress",
|
||||
"wargaming",
|
||||
"winrate"
|
||||
],
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
the [Official Discord Server](https://discord.gg/nDt7AjGJQH).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 TrèsAbhi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,25 @@
|
||||
import { DefaultTheme, defineConfig } from 'vitepress';
|
||||
import { getSidebar } from 'vitepress-plugin-auto-sidebar';
|
||||
|
||||
export default defineConfig({
|
||||
title: 'blitzkrieg',
|
||||
description: '🎉 All-in-one Discord bot for everything World of Tanks Blitz',
|
||||
base: '/blitzkrieg/',
|
||||
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{ text: 'Home', link: '/' },
|
||||
{ text: 'Examples', link: '/markdown-examples' },
|
||||
],
|
||||
|
||||
sidebar: getSidebar({
|
||||
collapsed: false,
|
||||
contentDirs: ['guide', 'legal', 'changelogs'],
|
||||
contentRoot: '/docs/',
|
||||
}) as DefaultTheme.Sidebar,
|
||||
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
// https://vitepress.dev/guide/custom-theme
|
||||
import { h } from 'vue'
|
||||
import Theme from 'vitepress/theme'
|
||||
import './style.css'
|
||||
|
||||
export default {
|
||||
extends: Theme,
|
||||
Layout: () => {
|
||||
return h(Theme.Layout, null, {
|
||||
// https://vitepress.dev/guide/extending-default-theme#layout-slots
|
||||
})
|
||||
},
|
||||
enhanceApp({ app, router, siteData }) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Customize default theme styling by overriding CSS variables:
|
||||
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
|
||||
*/
|
||||
|
||||
/**
|
||||
* Colors
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
:root {
|
||||
--vp-c-brand: #646cff;
|
||||
--vp-c-brand-light: #747bff;
|
||||
--vp-c-brand-lighter: #9499ff;
|
||||
--vp-c-brand-lightest: #bcc0ff;
|
||||
--vp-c-brand-dark: #535bf2;
|
||||
--vp-c-brand-darker: #454ce1;
|
||||
--vp-c-brand-dimm: rgba(100, 108, 255, 0.08);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component: Button
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
:root {
|
||||
--vp-button-brand-border: var(--vp-c-brand-light);
|
||||
--vp-button-brand-text: var(--vp-c-white);
|
||||
--vp-button-brand-bg: var(--vp-c-brand);
|
||||
--vp-button-brand-hover-border: var(--vp-c-brand-light);
|
||||
--vp-button-brand-hover-text: var(--vp-c-white);
|
||||
--vp-button-brand-hover-bg: var(--vp-c-brand-light);
|
||||
--vp-button-brand-active-border: var(--vp-c-brand-light);
|
||||
--vp-button-brand-active-text: var(--vp-c-white);
|
||||
--vp-button-brand-active-bg: var(--vp-button-brand-bg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component: Home
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
:root {
|
||||
--vp-home-hero-name-color: transparent;
|
||||
--vp-home-hero-name-background: -webkit-linear-gradient(
|
||||
120deg,
|
||||
#bd34fe 30%,
|
||||
#41d1ff
|
||||
);
|
||||
|
||||
--vp-home-hero-image-background-image: linear-gradient(
|
||||
-45deg,
|
||||
#bd34fe 50%,
|
||||
#47caff 50%
|
||||
);
|
||||
--vp-home-hero-image-filter: blur(40px);
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
:root {
|
||||
--vp-home-hero-image-filter: blur(56px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 960px) {
|
||||
:root {
|
||||
--vp-home-hero-image-filter: blur(72px);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Component: Custom Block
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
:root {
|
||||
--vp-custom-block-tip-border: var(--vp-c-brand);
|
||||
--vp-custom-block-tip-text: var(--vp-c-brand-darker);
|
||||
--vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--vp-custom-block-tip-border: var(--vp-c-brand);
|
||||
--vp-custom-block-tip-text: var(--vp-c-brand-lightest);
|
||||
--vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component: Algolia
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
.DocSearch {
|
||||
--docsearch-primary-color: var(--vp-c-brand) !important;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Blitzkrieg 1.3.0
|
||||
|
||||
This release of Blitzkrieg focuses mainly on **performance**. Blitzkrieg now uses **Satori** and **resvg** under the hood to render images resulting in a solid **2x to 8x performance boost** depending on the situation.
|
||||
|
||||
This only applies to `/today` and /stats` as they're the only commands that render an image currently.
|
||||
|
||||
We're working further on **performance optimizations**. Our goal is to deliver a message within **3 seconds or less**. We're close and we'll get there!
|
||||
|
||||
**Thank you to ba·ka**, the creator of aftermath, for telling me about Satori!
|
||||
@@ -0,0 +1,8 @@
|
||||
# Blitzkrieg 1.3.1
|
||||
|
||||
In this **minor update**, Blitzkrieg received several little **safety features** and **bug fixes**!
|
||||
|
||||
- The bot is now more verbose
|
||||
- Every time you use a command, the bot will now store data on what parameters you provided and if any errors were caused
|
||||
- This update also eliminates the redundant usage of truthy type checking after API calls
|
||||
- _Hopefully_ the bot let you know why it won't respond to you
|
||||
@@ -0,0 +1,5 @@
|
||||
# Blitzkrieg 1.3.2
|
||||
|
||||
From now on, I **won't be pinging** the Blitzkrieg role for minor updates. Anyway, this **minor update** includes an optimization for `/today`. The tank icons on the left were fetched every time someone used the command. The bot now caches those images allowing for an instantaneous load.
|
||||
|
||||
I noticed rendering times up to `3000ms` for rendering stats of about 10 tanks. Cached images should now be indifferent to this.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Blitzkrieg 1.3.3
|
||||
|
||||
This **minor update** fixes a few things :partying_face:
|
||||
|
||||
- Rating battles now no longer count in `/today`
|
||||
- This resolves the issue where some tanks had `NaN` stats
|
||||
- Stats with the value of `-Infinity` are now ommited
|
||||
- Images are not longer cached in `dev` `env`
|
||||
@@ -0,0 +1,28 @@
|
||||
# Blitzkrieg 1.4.0
|
||||
|
||||
A **few features** :star: and a **few much needed fixes** :wrench:!
|
||||
|
||||
## Changes
|
||||
|
||||
- Added an "today" row to `/today` which displays your overall statistics
|
||||
- Gave `/tankstats` the new blitzkrieg look
|
||||
- Also added "today", "60 days", and "career" stats
|
||||
- Added a beta warning to generated images
|
||||
- Updated the logo for match the new slate theme
|
||||
- Canary versions now use the canary logo variant
|
||||
- Added subtle polka dots to the background
|
||||
|
||||
## Fixes
|
||||
|
||||
- Rewrote `/stats` to precisely calculate stats on a per-tank basis
|
||||
- This should stop the bot from hallucinating about stats
|
||||
- This should also stop the bot from giving stats from like a week ago
|
||||
- Also added "60 day" stats
|
||||
- Tank autocomplete is now more human-tolerant just like username autocomplete
|
||||
- Titlebar discriminators are now truncated on overflow
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- The bot now uses `bepaint`, a library that I made that standardizes the color palette
|
||||
- Also updated the logo to follow this
|
||||
- Optimized how fonts are imported by fetching them all asynchronously
|
||||
@@ -0,0 +1,3 @@
|
||||
# Blitzkrieg 1.4.1
|
||||
|
||||
A quick fix for the `/help` command not accepting the new theme colors.
|
||||
@@ -0,0 +1,23 @@
|
||||
# Blitzkrieg 1.5.0
|
||||
|
||||
So so many **quality-of-life** changes and nasty **bug squashes**!
|
||||
|
||||
## Changes
|
||||
|
||||
- Added WN8 to `/today`, `/stats`, and `/tankstats`
|
||||
- Added average tier to `/stats` and `/tankstats`
|
||||
- Average tier in `/tankstats` is simply the tier of the tank that you are looking up
|
||||
- Added an indicator of WN8 ranging from "very bad" (gray) to "super unicum" (purple)
|
||||
- Replaced ellipses with simple clipping
|
||||
- Added a "large image" warning to `/today` if displaying `6` or more tanks
|
||||
|
||||
## Fixes
|
||||
|
||||
- Removed random 0 that'd show up in `/today` where there was no difference between career and today's stats
|
||||
- Added stricter checks for username autocomplete via a new REGEX pattern
|
||||
- Fixed wonky ellipses that'd cut off usernames, tank names, and clan names unnecessarily
|
||||
- Fixed the delta indicator showing up in battle counts
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Optimized and cleaned up tankopedia cache
|
||||
@@ -0,0 +1,3 @@
|
||||
# Blitzkrieg 1.5.1
|
||||
|
||||
An emergency patch that fixes failed image caching.
|
||||
@@ -0,0 +1,14 @@
|
||||
# Blitzkrieg 1.5.2
|
||||
|
||||
Quite a few **bug fixes** with a **bunch more** on their way next update!
|
||||
|
||||
## Fixes
|
||||
|
||||
- Disabled image encoding as it seems to have broken in `1.5.0` and simply spams the console now
|
||||
- `/stats` now ignores tanks that don't have any averages
|
||||
- Tanks may not have averages registered in Blitz Stars because they are new or are in testing
|
||||
- Take a look at \_34's testing tanks in the image below
|
||||
- Fixed the "large image" prompt by simply removing the whole prompt
|
||||
- _Kaboom? Yes Rico, kaboom._
|
||||
- `/today` now displays `--` when there is no WN8 to display
|
||||
- This is unlike `/stats` which just shows 0 (this will be fixed soon)
|
||||
@@ -0,0 +1,10 @@
|
||||
# Blitzkrieg 1.5.3
|
||||
|
||||
Just a few more fixes that weren't that important so were deffered to this update.
|
||||
|
||||
## Fixes
|
||||
|
||||
- `/stats` now uses `--` just like `/today` when WN8 is not available
|
||||
- Removed an unnecessary try/catch during the execution of a command
|
||||
- Added error handling for an edge case where accounts with 0 battles were looked up
|
||||
- This only applies to when `api/tanks/stats` is fetched; most other commands still need this fix
|
||||
@@ -0,0 +1,8 @@
|
||||
# Blitzkrieg 1.5.4
|
||||
|
||||
A last batch of fixes before the next update!
|
||||
|
||||
## Fixes
|
||||
|
||||
- Career WN8 in the `/today` command now accumulates the WN8 for all tanks instead of just the ones shown
|
||||
- WN8 and average tiers are now displayed in `/stats` in the `career` period
|
||||
@@ -0,0 +1,25 @@
|
||||
# Blitzkrieg 1.6.0
|
||||
|
||||
Spread the beauty! Spread the ease!
|
||||
|
||||
## Features
|
||||
|
||||
- Commands no longer require you to provide an username
|
||||
- They are automatically inferred from your Discord nickname
|
||||
- Re-implemented the `/eligible` command
|
||||
- This command checks a player's eligibility for any of the Skilled clans
|
||||
- This command is only available in the [Skilled](https://discord.gg/ZPvcEG7DS8) and [TresAbhi Discord](https://discord.gg/nDt7AjGJQH) servers
|
||||
- Gave `/ownedtanks` and `/inactive` the new Blitzkrieg look
|
||||
- Added "Powered by Wargaming" to commands where Blitz Stars is not utilized
|
||||
|
||||
## Fixes
|
||||
|
||||
- Removed image encoding all together
|
||||
- As it turns out, encoding them in `base64` made rendering slower!
|
||||
- Tank images in `/today` now don't make parent rows incorrectly taller
|
||||
- Added a "No tanks found" when a player does not own tanks in a tier
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Added a mature error handling system
|
||||
- Commands can now just `throw errorWithCause(...)` without caring about the error reporting to the user
|
||||
@@ -0,0 +1,20 @@
|
||||
# Blitzkrieg 1.7.0
|
||||
|
||||
This is mostly a technical update to make migrating to cyclic.sh easier.
|
||||
|
||||
## Changes
|
||||
|
||||
- The bot's new deferred caching approach allows the bot to start up almost `4x` as fast
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Made numerous caches non-blocking
|
||||
- Removed an unnecessary root-blocking await where fonts are imported
|
||||
- Further improved performance by deferring font imports until after the declaration
|
||||
- Tank averages and tankopedia are now declared fully empty only to be populated after a deferred fetch
|
||||
- Reordered error handler, client login, and client event listener registration orders
|
||||
- Removed `vite` all together
|
||||
- This reduces bundle sizes
|
||||
- To do this, a more primitive way of importing commands is used
|
||||
- Removed the redundant usage of `args` to get the Discord token and Wargaming Application ID on each use
|
||||
- Added a build script using `esbuild`
|
||||
@@ -0,0 +1,3 @@
|
||||
# Blitzkrieg 1.7.1
|
||||
|
||||
A hot fix to bring the bot back online with `vite-node`.
|
||||
@@ -0,0 +1,7 @@
|
||||
# Blitzkrieg 1.7.2
|
||||
|
||||
A quick, tiny, cute bug fix
|
||||
|
||||
## Fixes
|
||||
|
||||
- Tanks now once again show up in `/tankstats`
|
||||
@@ -0,0 +1,3 @@
|
||||
# Blitzkrieg 1.7.3 & 1.7.4
|
||||
|
||||
These minor updates fix compatibility issues with cyclic.
|
||||
@@ -0,0 +1,11 @@
|
||||
# Blitzkrieg 1.7.5
|
||||
|
||||
This minor release aids the migration to build-based hosting.
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Removed `env` logging
|
||||
- Fixed constant IDs and token naming conventions
|
||||
- Moved `esbuild` to a `js` script
|
||||
- Updated the workflow to use the latest binaries
|
||||
- Added a `zip` command for `dist`
|
||||
@@ -0,0 +1,14 @@
|
||||
# Blitzkrieg 1.7.6
|
||||
|
||||
Public service announcements and a few developer quality-of-life changes.
|
||||
|
||||
## Changes
|
||||
|
||||
- Added a PSA system
|
||||
- Lets me create announcements without having to release a new update every single time
|
||||
- Added fixed choices for tank stats instead of typing in numbers like before
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Command executions now return a payload and the executor now fully handles the interaction replies
|
||||
- The build script now skips certain steps to speed up building time when building in dev mode
|
||||
@@ -0,0 +1,7 @@
|
||||
# Blitzkrieg 1.7.7
|
||||
|
||||
A tiny fix related to hosting.
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- `index.cjs` is now run at root instead of `dist`
|
||||
@@ -0,0 +1,26 @@
|
||||
# Blitzkrieg 1.8.0
|
||||
|
||||
A slick new command and new potentials unlocked.
|
||||
|
||||
## Changes
|
||||
|
||||
- Added `/ping`
|
||||
- Allows you to see if the bot and Blitz are alive
|
||||
- Added custom periods for `/stats`
|
||||
- To do this, `/stats` received two sub command groups: `/stats player` and `/stats tank` (hence merging the two)
|
||||
- All periods, including cusotm ones, now live as subcommands
|
||||
- Added tier weights to `/stats`
|
||||
- Added `/evolution`
|
||||
- Shows your winrate and battles over a period
|
||||
|
||||
## Fixes
|
||||
|
||||
- `Infinity` and `NaN` values now show up as `--` in `/stats`
|
||||
- WN8 shortcomings in `/eligible` now rounds to nearest integer
|
||||
- Average tiers now, once again, show up in `/stats`
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Dev command names are implemented centrally in `interactionCreated`
|
||||
- Abstracted the renderers of `/stats`, `/evolution`, and `/today`
|
||||
- The bot now logs the number of server it's in on start up
|
||||
@@ -0,0 +1,7 @@
|
||||
# Blitzkrieg 1.8.1
|
||||
|
||||
A tiny oversight fixed.
|
||||
|
||||
# Fixes
|
||||
|
||||
- The min and max dates now show up in `/evolution`
|
||||
@@ -0,0 +1,32 @@
|
||||
# Blitzkrieg 1.9.0
|
||||
|
||||
The biggest, the baddest update yet!
|
||||
|
||||
## Changes
|
||||
|
||||
- Spiced up `/stats` with a graphics update
|
||||
- This command now only shows a few of the stats as most of them were pretty pointless
|
||||
- Renamed the old `/stats` to `/statsfull`
|
||||
- Added embeds for `/stats`
|
||||
- This is a URL that can be visited to load a "naked" variant of the command that auto-refreshes with the latest data every `60` seconds meant to be used the streamers
|
||||
- Added refresh buttons to a few commands
|
||||
- This lets you reuse a command on the click of a button
|
||||
- Fixed many readibility issues with `/evolution` thanks to @heldenklage
|
||||
|
||||
## Fixes
|
||||
|
||||
- Fixed several type issues for compatibility with `express`
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Added a seperate `server.ts` from `bot.ts`
|
||||
- Split builds appropriately
|
||||
- Added the ability for routes to respond with svg counterparts of commands
|
||||
- Cached `tankopedia.json` and `tankaverages.json` at build time
|
||||
- This may be reverted in a minor release i favor of `Promise<Tankopedia>`
|
||||
- Organized files as it was important to seperate the server and the bot code
|
||||
- Split `resolvePeriod` and `resolvePlayer` for command, button, and express counterparts
|
||||
- Switched a few instances of `Number(...)` to `parseInt(...)` and `parseLong(...)`
|
||||
- Disabled canary commands for the public
|
||||
- Merged `poweredBy` footers
|
||||
- `dist` now ships with a `package.json` for Cyclic
|
||||
@@ -0,0 +1,3 @@
|
||||
# Blitzkrieg 1.9.1
|
||||
|
||||
Created a website for Blitzkrieg! Check it out: https://tresabhi.github.io/blitzkrieg/
|
||||
@@ -0,0 +1,5 @@
|
||||
# Blitzkrieg 1.9.2
|
||||
|
||||
## Fixes
|
||||
|
||||
- Implemented `/blitzkrieg/` as the base path
|
||||
@@ -0,0 +1,14 @@
|
||||
# Blitzkrieg 1.9.3
|
||||
|
||||
A few fixes before we tackle the next major release.
|
||||
|
||||
## Fixes
|
||||
|
||||
- `/stats`, `/evolution`, and `/statsfull` now properly handle unowned or unplayed tanks
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- Added a `Command` suffix after all command exports
|
||||
- Added a `Route` suffix after all route exports
|
||||
- Moved `tankopedia` and `tankaverages` into a runtime cache
|
||||
- But, this time, it's a promise so we get the best of both worlds
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blitzkrieg 1.9.4
|
||||
|
||||
Haha, I lied. More fixes.
|
||||
|
||||
## Fixes
|
||||
|
||||
- Tank names once again show when searching for tank stats
|
||||
- Tier weights now ignore tanks without entries in the `tankopedia`
|
||||
|
||||
## Technical Changes
|
||||
|
||||
- All `tankopedia` derivatives are now promises
|
||||
@@ -0,0 +1,17 @@
|
||||
# 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!
|
||||
@@ -0,0 +1,6 @@
|
||||
# Permissions
|
||||
|
||||
The following Discord permissions are required by the bot to ensure full functionality:
|
||||
|
||||
- Attach files
|
||||
- View channels
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: 'blitzkrieg'
|
||||
text: Everything Blitz, right in Discord
|
||||
tagline: All-in-one Discord bot for everything World of Tanks Blitz
|
||||
image:
|
||||
src: '/assets/images/hero.png'
|
||||
alt: 'blitzkrieg'
|
||||
actions:
|
||||
- theme: brand
|
||||
text: Add to Discord Server
|
||||
link: guide/install
|
||||
- theme: alt
|
||||
text: Guide
|
||||
link: /guide
|
||||
|
||||
features:
|
||||
- title: Clean and Efficient UI
|
||||
icon: 🚀
|
||||
details: Blitzkrieg is where concise meets efficient. Get the information you need in the way you want.
|
||||
- title: Endless Possibilities
|
||||
icon: 🛠
|
||||
details: With endless ways to customize the output, it's guaranteed that you'll always get the information you need.
|
||||
- title: Easy to Use
|
||||
icon: 💻
|
||||
details: Leveraging Discord's, Blitz Stars', and Wargaming's powerful APIS, Blitzkrieg does all the hard work for you.
|
||||
---
|
||||
@@ -0,0 +1,23 @@
|
||||
# Blitzkrieg Privacy Policy
|
||||
|
||||
Blitzkrieg collects little to no data. Regardless, here is an exhaustive list of Blitzkrieg's data collection practices.
|
||||
|
||||
## Logs
|
||||
|
||||
All Blitzkrieg logs are available to the public as an effort for open source transparency. A history of all logs [can be found on GitHub](https://github.com/tresabhi/blitzkrieg/actions/workflows/host.yml). All logs expire automatically and are permanently deleted after 30 days. However, anyone may chose to save a local copy of the logs which is not tracked by GitHub.
|
||||
|
||||
## Commands
|
||||
|
||||
Everytime a command a command is used, the command name and parameters provided is logged. Any identifying information like manually provided in-game usernames are also recorded.
|
||||
|
||||
## Errors
|
||||
|
||||
Everytime an error occurs, a detailed stack trace, scope of the error, and the error message is logged both in the GitHub logs and in the public channel [#🔲︱blitzkrieg-logs](https://discord.com/channels/734786591205359697/880650462540476416) in [the official Discord server](https://discord.gg/nDt7AjGJQH).
|
||||
|
||||
## Databases
|
||||
|
||||
No databases are used by Blitzkrieg meaning that no data is collected outside of what has already been mentioned above. This is no permanent state.
|
||||
|
||||
## 3rd Party
|
||||
|
||||
The privacy policies of Discord, Wargaming, and Blitz Stars apply too since they are utilized by the bot.
|
||||
@@ -0,0 +1,13 @@
|
||||
# Blitzkrieg Terms of Service
|
||||
|
||||
## About
|
||||
|
||||
Blitzkrieg is a multi-function Discord bot that serves users with needs specific to the game World of Tanks Blitz.
|
||||
|
||||
## License
|
||||
|
||||
Blitzkrieg is licensed under the MIT License.
|
||||
|
||||
## 3rd Party
|
||||
|
||||
The terms of services of Discord, Wargaming, and Blitz Stars apply too since they are utilized by the bot.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"main": "server.js",
|
||||
"main": "server.cjs",
|
||||
"scripts": {
|
||||
"start": "node --enable-source-maps server.cjs"
|
||||
"start": "node --enable-source-maps --trace-warnings server.cjs"
|
||||
}
|
||||
}
|
||||
+20
-10
@@ -1,16 +1,22 @@
|
||||
{
|
||||
"name": "blitzkrieg",
|
||||
"version": "1.7.7",
|
||||
"version": "1.9.4",
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"main": "src/server.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "yarn build:raw --dev && yarn start --dev",
|
||||
"start": "node --enable-source-maps --trace-warnings dist/index.cjs",
|
||||
"build:bot": "node scripts/build --build=bot",
|
||||
"build:server": "node scripts/build --build=server",
|
||||
"build:docs": "vitepress build docs",
|
||||
"build": "node scripts/build --build=all",
|
||||
"dev:bot": "yarn build:bot --dev && yarn start:bot",
|
||||
"dev:server": "yarn build:server --dev && yarn start:server",
|
||||
"dev:docs": "vitepress dev docs",
|
||||
"start:bot": "node --enable-source-maps --trace-warnings dist/bot.cjs",
|
||||
"start:server": "node --enable-source-maps --trace-warnings dist/server.cjs",
|
||||
"host:docs": "vitepress preview docs",
|
||||
"zip": "zip -r dist.zip dist",
|
||||
"build:raw": "node scripts/build",
|
||||
"build": "yarn lint && yarn build:raw",
|
||||
"lint": "tsc"
|
||||
"lint": "npx tsc"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -18,21 +24,25 @@
|
||||
"@resvg/resvg-js": "^2.4.1",
|
||||
"bepaint": "^0.1.0-beta.3",
|
||||
"discord.js": "^14.9.0",
|
||||
"esbuild": "^0.18.10",
|
||||
"escape-html": "^1.0.3",
|
||||
"express": "^4.18.2",
|
||||
"fuzzysort": "^2.0.4",
|
||||
"lodash": "^4.17.21",
|
||||
"markdown-escape": "^2.0.0",
|
||||
"react": "^18.2.0",
|
||||
"satori": "^0.9.1"
|
||||
"satori": "^0.9.1",
|
||||
"vitepress-plugin-auto-sidebar": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@total-typescript/ts-reset": "^0.4.2",
|
||||
"@types/escape-html": "^1.0.2",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/lodash": "^4.14.195",
|
||||
"@types/markdown-escape": "^1.1.0",
|
||||
"@types/node": "^20.2.1",
|
||||
"@types/react": "^18.2.7",
|
||||
"esbuild": "^0.17.19",
|
||||
"typescript": "^5.0.4"
|
||||
"typescript": "^5.0.4",
|
||||
"vitepress": "^1.0.0-beta.3"
|
||||
}
|
||||
}
|
||||
+45
-10
@@ -1,18 +1,29 @@
|
||||
import { build } from 'esbuild';
|
||||
import { rmSync } from 'fs';
|
||||
import { copyFile, mkdir, rm } from 'fs/promises';
|
||||
import { argv } from 'process';
|
||||
|
||||
const isDev = argv.includes('--dev');
|
||||
const isProd = !isDev;
|
||||
const isProd = !argv.includes('--dev');
|
||||
const buildAll = argv.includes('--build=all');
|
||||
const buildBot = argv.includes('--build=bot') | buildAll;
|
||||
const buildServer = argv.includes('--build=server') | buildAll;
|
||||
|
||||
console.log('Removing dist...');
|
||||
rmSync('dist', { recursive: true, force: true });
|
||||
if (isProd) {
|
||||
// only remove in production to ensure no time is wasted in dev
|
||||
console.log('🟡 Removing dist...');
|
||||
await rm('dist', { recursive: true, force: true });
|
||||
console.log('✅ Dist removed');
|
||||
|
||||
console.log('Building...');
|
||||
build({
|
||||
entryPoints: ['src/index.ts'],
|
||||
outfile: 'dist/index.cjs',
|
||||
console.log('🟡 Creating dist...');
|
||||
await mkdir('dist');
|
||||
console.log('✅ Dist created');
|
||||
|
||||
console.log('🟡 Copying package.json...');
|
||||
copyFile('package.dist.json', 'dist/package.json').then(() =>
|
||||
console.log('✅ package.json copied'),
|
||||
);
|
||||
}
|
||||
|
||||
const commonOptions = {
|
||||
platform: 'node',
|
||||
loader: {
|
||||
'.node': 'copy',
|
||||
@@ -26,4 +37,28 @@ build({
|
||||
minifyWhitespace: isProd,
|
||||
|
||||
logLevel: isProd ? 'info' : 'silent',
|
||||
});
|
||||
};
|
||||
|
||||
if (buildBot) {
|
||||
console.log('🟡 Building bot...');
|
||||
build({
|
||||
...commonOptions,
|
||||
|
||||
entryPoints: ['src/bot.ts'],
|
||||
outfile: 'dist/bot.cjs',
|
||||
}).then(() => {
|
||||
console.log('✅ Bot built');
|
||||
});
|
||||
}
|
||||
|
||||
if (buildServer) {
|
||||
console.log('🟡 Building server...');
|
||||
build({
|
||||
...commonOptions,
|
||||
|
||||
entryPoints: ['src/server.ts'],
|
||||
outfile: 'dist/server.cjs',
|
||||
}).then(() => {
|
||||
console.log('✅ Server built');
|
||||
});
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import { DISCORD_TOKEN } from './core/process/args.js';
|
||||
import { DISCORD_TOKEN } from './core/node/arguments.js';
|
||||
import { registerErrorHandlers } from './events/error.js';
|
||||
import guildMemberAdd from './events/guildMemberAdd.js';
|
||||
import interactionCreate from './events/interactionCreate.js';
|
||||
import interactionCreate from './events/interactionCreate/index.js';
|
||||
import ready from './events/ready.js';
|
||||
|
||||
export const client = new Client({
|
||||
+13
-13
@@ -1,31 +1,31 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||
import { client } from '../bot.js';
|
||||
import { tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cleanTable from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import getClientId from '../core/process/getClientId.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import { client } from '../index.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable from '../core/discord/markdownTable.js';
|
||||
import getClientId from '../core/node/getClientId.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
const executionStart = new Date().getTime();
|
||||
|
||||
export default {
|
||||
export const debugCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('debug')
|
||||
.setDescription('Debug information about the bot'),
|
||||
|
||||
execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const currentTime = new Date().getTime();
|
||||
const uptime = currentTime - executionStart;
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${client.user?.username} debug information`,
|
||||
cleanTable([
|
||||
markdownTable([
|
||||
['Version', packageJSON.version],
|
||||
['Client ID', getClientId()],
|
||||
['Tag', interaction.client.user.tag],
|
||||
@@ -37,9 +37,9 @@ export default {
|
||||
(uptime / 1000) % 60,
|
||||
)}s ${Math.floor(uptime % 1000)}ms`,
|
||||
],
|
||||
['Tankopedia cached', `${tankopedia !== undefined}`],
|
||||
['Tank averages cached', `${tankAverages !== undefined}`],
|
||||
['Tankopedia cached', `${(await tankopedia) !== undefined}`],
|
||||
['Tank averages cached', `${(await tankAverages) !== undefined}`],
|
||||
]),
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
+63
-47
@@ -1,20 +1,21 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import getWN8 from '../core/blitz/getWN8.js';
|
||||
import calculateWN8 from '../core/blitz/calculateWN8.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import sumStats from '../core/blitz/sumStats.js';
|
||||
import { tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import getPeriodNow from '../core/blitzstars/getPeriodNow.js';
|
||||
import getPeriodStart from '../core/blitzstars/getPeriodStart.js';
|
||||
import getTankStatsOverTime from '../core/blitzstars/getTankStatsOverTime.js';
|
||||
import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cleanTable, { TableInput } from '../core/interaction/cleanTable.js';
|
||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import embedNegative from '../core/discord/embedNegative.js';
|
||||
import embedPositive from '../core/discord/embedPositive.js';
|
||||
import markdownTable, { TableInput } from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { PossiblyPromise } from '../types/possiblyPromise.js';
|
||||
|
||||
export type SkilledClan = 'SKLLD' | 'SMRI';
|
||||
|
||||
@@ -23,9 +24,9 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
|
||||
SMRI: 'Samurai',
|
||||
};
|
||||
|
||||
export default {
|
||||
export const eligibleCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: false,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -44,11 +45,11 @@ export default {
|
||||
)
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||
const { id, server } = await resolvePlayer(interaction);
|
||||
const { id, server } = await resolvePlayerFromCommand(interaction);
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
@@ -58,7 +59,7 @@ export default {
|
||||
let body = '';
|
||||
|
||||
if (clan === 'SKLLD') {
|
||||
const tankStatsOverTime = await getTankStatsOverTime(
|
||||
const tankStatsOverTime = await getTankStatsDiffed(
|
||||
server,
|
||||
id,
|
||||
getPeriodStart('30'),
|
||||
@@ -67,41 +68,56 @@ export default {
|
||||
const entries = Object.entries(tankStatsOverTime);
|
||||
const stats = sumStats(entries.map(([, stats]) => stats));
|
||||
const averageTier =
|
||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankTier = tankopedia[tankId].tier;
|
||||
(await entries.reduce<PossiblyPromise<number>>(
|
||||
async (accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankTier = (await tankopedia)[tankId].tier;
|
||||
|
||||
return accumulator + tankTier * stats.battles;
|
||||
}, 0) / stats.battles;
|
||||
return (await accumulator) + tankTier * stats.battles;
|
||||
},
|
||||
0,
|
||||
)) / stats.battles;
|
||||
const WN8 =
|
||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
(await entries.reduce<PossiblyPromise<number>>(
|
||||
async (accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
|
||||
// edge case where new tanks don't have averages
|
||||
if (tankAverages[tankId]) {
|
||||
const tankWN8 = getWN8(tankAverages[tankId].all, stats);
|
||||
// edge case where new tanks don't have averages
|
||||
if ((await tankAverages)[tankId]) {
|
||||
const tankWN8 = calculateWN8(
|
||||
(await tankAverages)[tankId].all,
|
||||
stats,
|
||||
);
|
||||
|
||||
if (isNaN(tankWN8)) return accumulator;
|
||||
return accumulator + tankWN8 * stats.battles;
|
||||
} else return accumulator;
|
||||
}, 0) / stats.battles;
|
||||
if (isNaN(tankWN8)) return accumulator;
|
||||
return (await accumulator) + tankWN8 * stats.battles;
|
||||
} else return accumulator;
|
||||
},
|
||||
0,
|
||||
)) / stats.battles;
|
||||
const tier10Damage =
|
||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
(await entries.reduce<PossiblyPromise<number>>(
|
||||
async (accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
|
||||
if (tankopedia[tankId]?.tier === 10) {
|
||||
const tankStats = tankStatsOverTime[tankId];
|
||||
return accumulator + tankStats.damage_dealt;
|
||||
} else return accumulator;
|
||||
}, 0) /
|
||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
if ((await tankopedia)[tankId]?.tier === 10) {
|
||||
const tankStats = tankStatsOverTime[tankId];
|
||||
return (await accumulator) + tankStats.damage_dealt;
|
||||
} else return accumulator;
|
||||
},
|
||||
0,
|
||||
)) /
|
||||
(await entries.reduce<PossiblyPromise<number>>(
|
||||
async (accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
|
||||
if (tankopedia[tankId]?.tier === 10) {
|
||||
const tankStats = tankStatsOverTime[tankId];
|
||||
return accumulator + tankStats.battles;
|
||||
} else return accumulator;
|
||||
}, 0);
|
||||
if ((await tankopedia)[tankId]?.tier === 10) {
|
||||
const tankStats = tankStatsOverTime[tankId];
|
||||
return (await accumulator) + tankStats.battles;
|
||||
} else return accumulator;
|
||||
},
|
||||
0,
|
||||
));
|
||||
|
||||
if (stats.battles < 126) {
|
||||
problems.push(['Battles', `${stats.battles} (${stats.battles - 126})`]);
|
||||
@@ -137,7 +153,7 @@ export default {
|
||||
isEligible = problems.length === 0;
|
||||
body = isEligible
|
||||
? 'Player is fully eligible.'
|
||||
: `Player is not eligible. Shortcomings in 30-day statistics:\n\n${cleanTable(
|
||||
: `Player is not eligible. Shortcomings in 30-day statistics:\n\n${markdownTable(
|
||||
problems,
|
||||
)}`;
|
||||
} else if (clan === 'SMRI') {
|
||||
@@ -162,11 +178,11 @@ export default {
|
||||
isEligible = problems.length === 0;
|
||||
body = isEligible
|
||||
? 'Player is fully eligible.'
|
||||
: `Player is not eligible. Shortcomings in career statistics:\n\n${cleanTable(
|
||||
: `Player is not eligible. Shortcomings in career statistics:\n\n${markdownTable(
|
||||
problems,
|
||||
)}`;
|
||||
}
|
||||
|
||||
return (isEligible ? positiveEmbed : negativeEmbed)(title, body);
|
||||
return (isEligible ? embedPositive : embedNegative)(title, body);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
+65
-29
@@ -1,50 +1,86 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import tanksAutocomplete from '../core/autocomplete/tanks.js';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import { CYCLIC_API } from '../constants/cyclic.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import resolvePeriod from '../core/options/resolvePeriod.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js';
|
||||
import autocompleteTanks from '../core/discord/autocompleteTanks.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import interactionToURL from '../core/discord/interactionToURL.js';
|
||||
import linkButton from '../core/discord/linkButton.js';
|
||||
import primaryButton from '../core/discord/primaryButton.js';
|
||||
import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import evolution from '../renderers/evolution.js';
|
||||
import { StatType } from '../renderers/stats.js';
|
||||
import { StatType } from '../renderers/statsfull.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
export const evolutionCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatsSubCommandGroups(
|
||||
command: addStatTypeSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName('evolution')
|
||||
.setDescription('Evolution of statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup(
|
||||
true,
|
||||
) as StatType;
|
||||
const player = await resolvePlayer(interaction);
|
||||
const period = resolvePeriod(interaction);
|
||||
const player = await resolvePlayerFromCommand(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const tankIdRaw = interaction.options.getString('tank')!;
|
||||
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : 0;
|
||||
const tankId = commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null;
|
||||
const start = interaction.options.getInteger('start');
|
||||
const end = interaction.options.getInteger('end');
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
const path = interactionToURL(interaction, {
|
||||
...player,
|
||||
tankId,
|
||||
start,
|
||||
end,
|
||||
});
|
||||
|
||||
return await evolution(commandGroup, period, player, tankId);
|
||||
|
||||
// new ButtonBuilder()
|
||||
// .setStyle(ButtonStyle.Link)
|
||||
// .setLabel('View on BlitzStars')
|
||||
// .setURL(
|
||||
// commandGroup === 'tank'
|
||||
// ? `https://www.blitzstars.com/player/com/${
|
||||
// accountInfo[id].nickname
|
||||
// }/tank/${tankId!}`
|
||||
// : `https://www.blitzstars.com/player/com/${accountInfo[id].nickname}`,
|
||||
// );
|
||||
return [
|
||||
await evolution(commandGroup, period, player, tankId),
|
||||
primaryButton(path, 'Refresh'),
|
||||
// linkButton(`${CYCLIC_API}/${path}`, 'Embed'),
|
||||
linkButton(
|
||||
`https://www.blitzstars.com/player/${player.server}/${nickname}${
|
||||
commandGroup === 'tank' ? `/tank/${tankId!}` : ''
|
||||
}`,
|
||||
'BlitzStars',
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
autocomplete: (interaction) => {
|
||||
usernameAutocomplete(interaction);
|
||||
tanksAutocomplete(interaction);
|
||||
autocompleteUsername(interaction);
|
||||
autocompleteTanks(interaction);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
|
||||
async button(interaction) {
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const path = url.pathname.split('/').filter(Boolean);
|
||||
const commandGroup = path[1] as StatType;
|
||||
const period = resolvePeriodFromButton(interaction);
|
||||
const player = await resolvePlayerFromButton(interaction);
|
||||
|
||||
return await evolution(
|
||||
commandGroup,
|
||||
period,
|
||||
player,
|
||||
parseInt(url.searchParams.get('tankId')!),
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,24 +1,24 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import { client } from '../bot.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import {
|
||||
CommandRegistry,
|
||||
guildCommands,
|
||||
publicCommands,
|
||||
} from '../events/interactionCreate.js';
|
||||
import { client } from '../index.js';
|
||||
} from '../events/interactionCreate/index.js';
|
||||
|
||||
export default {
|
||||
export const helpCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription('All the help you need about the bot'),
|
||||
|
||||
execute(interaction) {
|
||||
return infoEmbed(
|
||||
handler(interaction) {
|
||||
return embedInfo(
|
||||
`${client.user?.username} help`,
|
||||
`**About**\n${
|
||||
client.user?.username
|
||||
@@ -33,4 +33,4 @@ export default {
|
||||
)}\n\n*I am a new bot; I may make mistakes and go offline unexpectedly from time to time.*`,
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
+12
-12
@@ -1,24 +1,24 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import GenericStats from '../components/GenericStats/index.js';
|
||||
import NoData, { NoDataType } from '../components/NoData.js';
|
||||
import PoweredByWargaming from '../components/PoweredByWargaming.js';
|
||||
import PoweredBy, { PoweredByType } from '../components/PoweredBy.js';
|
||||
import TitleBar from '../components/TitleBar.js';
|
||||
import Wrapper from '../components/Wrapper.js';
|
||||
import { BLITZ_SERVERS } from '../constants/servers.js';
|
||||
import clanAutocomplete from '../core/autocomplete/clan.js';
|
||||
import getBlitzClan from '../core/blitz/getBlitzClan.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addClanChoices from '../core/options/addClanChoices.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addClanChoices from '../core/discord/addClanChoices.js';
|
||||
import autocompleteClan from '../core/discord/autocompleteClan.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { ClanInfo } from '../types/clanInfo.js';
|
||||
|
||||
const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export default {
|
||||
export const inactiveCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -34,9 +34,9 @@ export default {
|
||||
.setMinValue(0),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const clanName = interaction.options.getString('clan')!;
|
||||
const { server, id } = await getBlitzClan(interaction, clanName);
|
||||
const { server, id } = await getBlitzClan(clanName);
|
||||
const threshold =
|
||||
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
||||
const time = new Date().getTime() / 1000;
|
||||
@@ -79,10 +79,10 @@ export default {
|
||||
{!hasInactiveMembers && <NoData type={NoDataType.PlayersInPeriod} />}
|
||||
{hasInactiveMembers && <GenericStats stats={inactive} />}
|
||||
|
||||
<PoweredByWargaming />
|
||||
<PoweredBy type={PoweredByType.Wargaming} />
|
||||
</Wrapper>
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: clanAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
autocomplete: autocompleteClan,
|
||||
};
|
||||
@@ -1,11 +1,10 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import NoData, { NoDataType } from '../components/NoData.js';
|
||||
import PoweredByWargaming from '../components/PoweredByWargaming.js';
|
||||
import PoweredBy, { PoweredByType } from '../components/PoweredBy.js';
|
||||
import * as Tanks from '../components/Tanks/index.js';
|
||||
import TitleBar from '../components/TitleBar.js';
|
||||
import Wrapper from '../components/Wrapper.js';
|
||||
import { BLITZ_SERVERS } from '../constants/servers.js';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getTankStats from '../core/blitz/getTankStats.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import {
|
||||
@@ -13,10 +12,11 @@ import {
|
||||
Tier,
|
||||
tankopedia,
|
||||
} from '../core/blitz/tankopedia.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
@@ -41,9 +41,9 @@ const COMP_TANKS = [
|
||||
6753, // type 71
|
||||
];
|
||||
|
||||
export default {
|
||||
export const ownedTanksCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -67,19 +67,21 @@ export default {
|
||||
)
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const tier = Number(interaction.options.getString('tier'));
|
||||
const account = await resolvePlayer(interaction);
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, server } = account;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const tankStats = await getTankStats(server, id);
|
||||
const tanks = tankStats
|
||||
.map((tankData) => tankopedia[tankData.tank_id])
|
||||
.filter((tank) => tank?.tier === tier);
|
||||
const tanks = (
|
||||
await Promise.all(
|
||||
tankStats.map(async (tankData) => (await tankopedia)[tankData.tank_id]),
|
||||
)
|
||||
).filter((tank) => tank?.tier === tier);
|
||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||
);
|
||||
@@ -115,10 +117,10 @@ export default {
|
||||
</Tanks.Root>
|
||||
)}
|
||||
|
||||
<PoweredByWargaming />
|
||||
<PoweredBy type={PoweredByType.Wargaming} />
|
||||
</Wrapper>
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
autocomplete: autocompleteUsername,
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
export default {
|
||||
export const pingCommand: CommandRegistry<true> = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
handlesInteraction: true,
|
||||
|
||||
@@ -17,7 +17,7 @@ export default {
|
||||
option.setName('blitz').setDescription('Ping Blitz'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
const executionStart = Date.now();
|
||||
|
||||
@@ -30,4 +30,4 @@ export default {
|
||||
const executionTime = Date.now() - executionStart;
|
||||
interaction.editReply(`Pong 🏓 - ${executionTime}ms`);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
@@ -1,28 +1,30 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { startCase } from 'lodash';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import cleanTable, { TableInputEntry } from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable, {
|
||||
TableInputEntry,
|
||||
} from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountAchievements } from '../types/accountAchievements.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
type SortBy = 'name' | 'count';
|
||||
|
||||
export default {
|
||||
export const playerAchievementsCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('playerachievements')
|
||||
.setDescription("All the player's achievements")
|
||||
.addStringOption(addUsernameOption)
|
||||
.addStringOption(addUsernameChoices)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('sort')
|
||||
@@ -33,9 +35,9 @@ export default {
|
||||
),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const sortBy = (interaction.options.getString('sort') ?? 'name') as SortBy;
|
||||
const account = await resolvePlayer(interaction);
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
@@ -50,10 +52,10 @@ export default {
|
||||
...accountAchievements.max_series,
|
||||
};
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${markdownEscape(accounts[id].nickname)}'s information`,
|
||||
|
||||
cleanTable(
|
||||
markdownTable(
|
||||
Object.keys(compound)
|
||||
.filter((achievement) => compound[achievement] > 0)
|
||||
.sort(
|
||||
@@ -72,5 +74,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
autocomplete: autocompleteUsername,
|
||||
};
|
||||
@@ -1,37 +1,37 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import cleanTable from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
export const playerInfoCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('playerinfo')
|
||||
.setDescription('Basic information about a player')
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async execute(interaction) {
|
||||
const account = await resolvePlayer(interaction);
|
||||
async handler(interaction) {
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
const { id, server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
);
|
||||
const accountInfo = accounts[id];
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${markdownEscape(accountInfo.nickname)}'s information`,
|
||||
|
||||
cleanTable([
|
||||
markdownTable([
|
||||
['Nickname', `${accountInfo.nickname}`],
|
||||
['Battles', `${accountInfo.statistics.all.battles}`],
|
||||
[
|
||||
@@ -56,5 +56,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
autocomplete: autocompleteUsername,
|
||||
};
|
||||
@@ -2,16 +2,16 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addClanChoices from '../core/options/addClanChoices.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addClanChoices from '../core/discord/addClanChoices.js';
|
||||
import addServerChoices from '../core/discord/addServerChoices.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { ClanList } from '../types/clanList.js';
|
||||
|
||||
export default {
|
||||
export const searchClansCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const clan = interaction.options.getString('clan')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
@@ -35,7 +35,7 @@ export default {
|
||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||
);
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Clan search for "${markdownEscape(clan)}" in ${BLITZ_SERVERS[server]}`,
|
||||
clanList.length === 0
|
||||
? 'No clans found.'
|
||||
@@ -44,4 +44,4 @@ export default {
|
||||
.join('\n')}\n\`\`\``,
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
@@ -2,17 +2,17 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import { usernamePattern } from '../core/blitz/listAccountsPanServer.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import { usernamePattern } from '../core/blitz/listPlayers.js';
|
||||
import addServerChoices from '../core/discord/addServerChoices.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountList } from '../types/accountList.js';
|
||||
|
||||
export default {
|
||||
export const searchPlayersCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
.setDescription('Search players in a Blitz server')
|
||||
.addStringOption(addServerChoices)
|
||||
.addStringOption((option) =>
|
||||
addUsernameOption(option).setAutocomplete(false).setRequired(true),
|
||||
addUsernameChoices(option).setAutocomplete(false).setRequired(true),
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const name = interaction.options.getString('username')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
)
|
||||
: [];
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Player search for "${markdownEscape(name)}" in ${BLITZ_SERVERS[server]}`,
|
||||
`\`\`\`${
|
||||
players.length === 0
|
||||
@@ -52,4 +52,4 @@ export default {
|
||||
}\`\`\``,
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
@@ -2,13 +2,13 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { TANK_NAMES } from '../core/blitz/tankopedia.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addTankChoices from '../core/options/addTankChoices.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addTankChoices from '../core/discord/addTankChoices.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
export default {
|
||||
export const searchTanksCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -23,18 +23,18 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const tank = interaction.options.getString('tank')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const results = go(tank, TANK_NAMES, { limit }).map(
|
||||
const results = go(tank, await TANK_NAMES, { limit }).map(
|
||||
(result) => result.target,
|
||||
);
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Tank search for "${markdownEscape(tank)}"`,
|
||||
results.length === 0
|
||||
? 'No tanks found.'
|
||||
: `\`\`\`\n${results.join('\n')}\n\`\`\``,
|
||||
);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
+65
-18
@@ -1,38 +1,85 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import tanksAutocomplete from '../core/autocomplete/tanks.js';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import { CYCLIC_API } from '../constants/cyclic.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import resolvePeriod from '../core/options/resolvePeriod.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import stats, { StatType } from '../renderers/stats.js';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js';
|
||||
import autocompleteTanks from '../core/discord/autocompleteTanks.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import interactionToURL from '../core/discord/interactionToURL.js';
|
||||
import linkButton from '../core/discord/linkButton.js';
|
||||
import primaryButton from '../core/discord/primaryButton.js';
|
||||
import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import stats from '../renderers/stats.js';
|
||||
import { StatType } from '../renderers/statsfull.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
export const statsCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatsSubCommandGroups(
|
||||
command: addStatTypeSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName('stats')
|
||||
.setDescription('In-game statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup(
|
||||
true,
|
||||
) as StatType;
|
||||
const player = await resolvePlayer(interaction);
|
||||
const period = resolvePeriod(interaction);
|
||||
const player = await resolvePlayerFromCommand(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const tankIdRaw = interaction.options.getString('tank')!;
|
||||
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : 0;
|
||||
const tankId =
|
||||
commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null;
|
||||
const start = interaction.options.getInteger('start');
|
||||
const end = interaction.options.getInteger('end');
|
||||
const path = interactionToURL(interaction, {
|
||||
...player,
|
||||
tankId,
|
||||
start,
|
||||
end,
|
||||
});
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
|
||||
return await stats(commandGroup, period, player, tankId);
|
||||
return [
|
||||
await stats(commandGroup, period, player, tankId),
|
||||
primaryButton(path, 'Refresh'),
|
||||
linkButton(`${CYCLIC_API}/${path}`, 'Embed'),
|
||||
linkButton(
|
||||
`https://www.blitzstars.com/player/${player.server}/${nickname}`,
|
||||
'BlitzStars',
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
autocomplete: (interaction) => {
|
||||
usernameAutocomplete(interaction);
|
||||
tanksAutocomplete(interaction);
|
||||
autocompleteUsername(interaction);
|
||||
autocompleteTanks(interaction);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
|
||||
async button(interaction) {
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const path = url.pathname.split('/').filter(Boolean);
|
||||
const commandGroup = path[1] as StatType;
|
||||
const period = resolvePeriodFromButton(interaction);
|
||||
const player = await resolvePlayerFromButton(interaction);
|
||||
|
||||
return await stats(
|
||||
commandGroup,
|
||||
period,
|
||||
player,
|
||||
parseInt(url.searchParams.get('tankId')!),
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { CYCLIC_API } from '../constants/cyclic.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js';
|
||||
import autocompleteTanks from '../core/discord/autocompleteTanks.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import interactionToURL from '../core/discord/interactionToURL.js';
|
||||
import linkButton from '../core/discord/linkButton.js';
|
||||
import primaryButton from '../core/discord/primaryButton.js';
|
||||
import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import statsfull, { StatType } from '../renderers/statsfull.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export const statsFullCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatTypeSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName('statsfull')
|
||||
.setDescription('Full in-game statistics'),
|
||||
),
|
||||
|
||||
async handler(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup(
|
||||
true,
|
||||
) as StatType;
|
||||
const player = await resolvePlayerFromCommand(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const tankIdRaw = interaction.options.getString('tank')!;
|
||||
const tankId =
|
||||
commandGroup === 'tank' ? await resolveTankId(tankIdRaw) : null;
|
||||
const start = interaction.options.getInteger('start');
|
||||
const end = interaction.options.getInteger('end');
|
||||
const path = interactionToURL(interaction, {
|
||||
...player,
|
||||
tankId,
|
||||
start,
|
||||
end,
|
||||
});
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
|
||||
return [
|
||||
await statsfull(commandGroup, period, player, tankId),
|
||||
primaryButton(path, 'Refresh'),
|
||||
// linkButton(`${CYCLIC_API}/${path}`, 'Embed'),
|
||||
linkButton(
|
||||
`https://www.blitzstars.com/player/${player.server}/${nickname}`,
|
||||
'BlitzStars',
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
autocomplete: (interaction) => {
|
||||
autocompleteUsername(interaction);
|
||||
autocompleteTanks(interaction);
|
||||
},
|
||||
|
||||
async button(interaction) {
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const path = url.pathname.split('/').filter(Boolean);
|
||||
const commandGroup = path[1] as StatType;
|
||||
const period = resolvePeriodFromButton(interaction);
|
||||
const player = await resolvePlayerFromButton(interaction);
|
||||
|
||||
return await statsfull(
|
||||
commandGroup,
|
||||
period,
|
||||
player,
|
||||
parseInt(url.searchParams.get('tankId')!),
|
||||
);
|
||||
},
|
||||
};
|
||||
+39
-12
@@ -1,25 +1,52 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import interactionToURL from '../core/discord/interactionToURL.js';
|
||||
import linkButton from '../core/discord/linkButton.js';
|
||||
import primaryButton from '../core/discord/primaryButton.js';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import today from '../renderers/today.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
export const todayCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('today')
|
||||
.setDescription('A general daily breakdown of your performance')
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async execute(interaction) {
|
||||
const player = await resolvePlayer(interaction);
|
||||
async handler(interaction) {
|
||||
const player = await resolvePlayerFromCommand(interaction);
|
||||
const { nickname } = (
|
||||
await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${player.server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${player.id}`,
|
||||
)
|
||||
)[player.id];
|
||||
const path = interactionToURL(interaction, player);
|
||||
|
||||
return [
|
||||
await today(player),
|
||||
primaryButton(path, 'Refresh'),
|
||||
// linkButton(`${CYCLIC_API}/${path}`, 'Embed'),
|
||||
linkButton(
|
||||
`https://www.blitzstars.com/player/${player.server}/${nickname}`,
|
||||
'BlitzStars',
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
autocomplete: autocompleteUsername,
|
||||
|
||||
async button(interaction) {
|
||||
const player = await resolvePlayerFromButton(interaction);
|
||||
|
||||
return await today(player);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
};
|
||||
+19
-19
@@ -1,29 +1,29 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedNegative from '../core/discord/embedNegative.js';
|
||||
import embedPositive from '../core/discord/embedPositive.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
export const verifyCommand: CommandRegistry = {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('verify')
|
||||
.setDescription("Set's the user's username to their in-game name")
|
||||
.addStringOption((option) => addUsernameOption(option).setRequired(true)),
|
||||
.addStringOption((option) => addUsernameChoices(option).setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
const blitzAccount = await resolvePlayer(interaction);
|
||||
async handler(interaction) {
|
||||
const blitzAccount = await resolvePlayerFromCommand(interaction);
|
||||
const { id, server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
@@ -38,13 +38,13 @@ export default {
|
||||
interaction.guild?.members.cache.get(interaction.member?.user.id);
|
||||
|
||||
if (!interaction.guild?.members.me?.permissions.has('ManageNicknames')) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${markdownEscape(interaction.user.username)} failed to verify`,
|
||||
"I don't have the permission to change your nickname.",
|
||||
);
|
||||
}
|
||||
if (!interaction.member || !member) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${interaction.user.username} is not in this server`,
|
||||
"I couldn't find this person in this server. Did they leave?",
|
||||
);
|
||||
@@ -55,7 +55,7 @@ export default {
|
||||
|
||||
if (interaction.guildId === discord.sklld_guild_id) {
|
||||
if (!interaction.guild?.members.me?.permissions.has('ManageRoles')) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${markdownEscape(interaction.user.username)} failed to verify`,
|
||||
"I don't have the permission to change your manage roles.",
|
||||
);
|
||||
@@ -65,19 +65,19 @@ export default {
|
||||
await member.roles.add(discord.sklld_peasant_role);
|
||||
}
|
||||
|
||||
return positiveEmbed(
|
||||
return embedPositive(
|
||||
`${interaction.user.username} is verified`,
|
||||
`The user is now verified as ${markdownEscape(
|
||||
accountInfo[id].nickname,
|
||||
)}${markdownEscape(clanTag)}`,
|
||||
);
|
||||
} catch (error) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${interaction.user.username} failed to verify`,
|
||||
"I can't change your nickname because you have higher permissions than me. Try setting your nickname to your Blitz username manually.",
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
} satisfies CommandRegistry;
|
||||
autocomplete: autocompleteUsername,
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Percentile } from '../../../../../constants/percentiles.js';
|
||||
import hslToHex from '../../../../../core/node/hslToHex.js';
|
||||
import { PERCENTILE_COLORS } from '../../../../PercentileIndicator.js';
|
||||
|
||||
export enum GlowSide {
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
export interface GlowProps {
|
||||
percentile: Percentile;
|
||||
side: GlowSide;
|
||||
}
|
||||
|
||||
export function Glow({ percentile, side }: GlowProps) {
|
||||
const color = PERCENTILE_COLORS[percentile];
|
||||
const color1 = hslToHex(color);
|
||||
const color2 = `${color1}00`;
|
||||
|
||||
const background = `linear-gradient(${
|
||||
side === GlowSide.Top ? 0 : 180
|
||||
}deg, ${color1} 0%, ${color2} 100%)`;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: side === GlowSide.Top ? 'flex-end' : 'flex-start',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<div style={{ height: 54, width: 16, background }} />
|
||||
<div style={{ height: 72, width: 16, background }} />
|
||||
<div style={{ height: 80, width: 16, background }} />
|
||||
<div style={{ height: 72, width: 16, background }} />
|
||||
<div style={{ height: 54, width: 16, background }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Percentile } from '../../../../constants/percentiles.js';
|
||||
import getWN8Percentile from '../../../../core/blitz/getWN8Percentile.js';
|
||||
import { theme } from '../../../../stitches.config.js';
|
||||
import { PERCENTILE_COLORS } from '../../../PercentileIndicator.js';
|
||||
import { Glow, GlowSide } from './components/Glow.js';
|
||||
|
||||
export interface WN8DisplayProps {
|
||||
WN8?: number;
|
||||
}
|
||||
|
||||
export const PERCENTILE_NAMES = {
|
||||
[Percentile.VeryBad]: 'Very Bad',
|
||||
[Percentile.Bad]: 'Bad',
|
||||
[Percentile.BelowAverage]: 'Below Average',
|
||||
[Percentile.Average]: 'Average',
|
||||
[Percentile.AboveAverage]: 'Above Average',
|
||||
[Percentile.Good]: 'Good',
|
||||
[Percentile.VeryGood]: 'Very Good',
|
||||
[Percentile.Great]: 'Great',
|
||||
[Percentile.Unicum]: 'Unicum',
|
||||
[Percentile.SuperUnicum]: 'Super Unicum',
|
||||
};
|
||||
|
||||
export function WN8Display({ WN8 }: WN8DisplayProps) {
|
||||
const percentile =
|
||||
WN8 === undefined ? Percentile.VeryBad : getWN8Percentile(WN8);
|
||||
const color = PERCENTILE_COLORS[percentile];
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
width: 128 * 2, // idk why twice the width turns into the correct width
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: -16,
|
||||
}}
|
||||
>
|
||||
<Glow percentile={percentile} side={GlowSide.Top} />
|
||||
|
||||
<div
|
||||
style={{
|
||||
width: 128,
|
||||
height: 80,
|
||||
backgroundColor: color,
|
||||
borderRadius: 40,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: -4,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
fontWeight: 900,
|
||||
fontSize: 32,
|
||||
color: theme.colors.textHighContrast,
|
||||
}}
|
||||
>
|
||||
{WN8 === undefined ? '--' : WN8.toFixed(0)}
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: 16,
|
||||
color: theme.colors.textHighContrast,
|
||||
}}
|
||||
>
|
||||
{PERCENTILE_NAMES[percentile]}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Glow percentile={percentile} side={GlowSide.Bottom} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { theme } from '../../../stitches.config.js';
|
||||
|
||||
export enum WN8SurroundingStatAlign {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
export interface WN8SurroundingStatProps {
|
||||
label: string;
|
||||
value: string | number;
|
||||
align?: WN8SurroundingStatAlign;
|
||||
padded?: boolean;
|
||||
}
|
||||
|
||||
export function WN8SurroundingStat({
|
||||
label,
|
||||
value,
|
||||
align = WN8SurroundingStatAlign.Left,
|
||||
padded = false,
|
||||
}: WN8SurroundingStatProps) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems:
|
||||
align === WN8SurroundingStatAlign.Left ? 'flex-start' : 'flex-end',
|
||||
paddingLeft: padded && align === WN8SurroundingStatAlign.Left ? 32 : 0,
|
||||
paddingRight:
|
||||
padded && align === WN8SurroundingStatAlign.Right ? 32 : 0,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
color: theme.colors.textHighContrast,
|
||||
fontSize: 24,
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{value}
|
||||
</span>
|
||||
<span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
|
||||
{label}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { AllStats, SupplementaryStats } from '../../types/accountInfo.js';
|
||||
import { WN8Display } from './components/WN8Display/index.js';
|
||||
import {
|
||||
WN8SurroundingStat,
|
||||
WN8SurroundingStatAlign,
|
||||
} from './components/WN8SurroundingStat.js';
|
||||
|
||||
export interface AllStatsOverviewProps {
|
||||
stats: AllStats;
|
||||
supplementaryStats: SupplementaryStats;
|
||||
}
|
||||
|
||||
export default function AllStatsOverview({
|
||||
stats,
|
||||
supplementaryStats,
|
||||
}: AllStatsOverviewProps) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
gap: -64,
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 8,
|
||||
alignItems: 'flex-end',
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<WN8SurroundingStat
|
||||
label="Battles"
|
||||
value={stats.battles.toLocaleString()}
|
||||
align={WN8SurroundingStatAlign.Right}
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Winrate"
|
||||
value={`${(100 * (stats.wins / stats.battles)).toFixed(2)}%`}
|
||||
align={WN8SurroundingStatAlign.Right}
|
||||
padded
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Damage"
|
||||
value={Math.round(
|
||||
stats.damage_dealt / stats.battles,
|
||||
).toLocaleString()}
|
||||
align={WN8SurroundingStatAlign.Right}
|
||||
padded
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Dmg. ratio"
|
||||
value={(stats.damage_dealt / stats.damage_received).toFixed(2)}
|
||||
align={WN8SurroundingStatAlign.Right}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<WN8Display WN8={supplementaryStats.WN8} />
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 8,
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<WN8SurroundingStat
|
||||
label="Tier"
|
||||
value={supplementaryStats.tier.toFixed(2)}
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Survival"
|
||||
value={`${(100 * (stats.survived_battles / stats.battles)).toFixed(
|
||||
2,
|
||||
)}%`}
|
||||
padded
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Accuracy"
|
||||
value={`${(100 * (stats.hits / stats.shots)).toFixed(2)}%`}
|
||||
padded
|
||||
/>
|
||||
<WN8SurroundingStat
|
||||
label="Kill ratio"
|
||||
value={(
|
||||
stats.frags /
|
||||
(stats.battles - stats.survived_battles)
|
||||
).toFixed(2)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import getWN8Percentile from '../core/blitz/getWN8Percentile.js';
|
||||
import isNumber from '../core/process/isNumber.js';
|
||||
import isNumber from '../core/node/isNumber.js';
|
||||
import { AllStats, SupplementaryStats } from '../types/accountInfo.js';
|
||||
import GenericStats from './GenericStats/index.js';
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { blue, green, red } from '@radix-ui/colors';
|
||||
import { blue, green, red, slateDark } from '@radix-ui/colors';
|
||||
import { GRAPH_HEIGHT, GRAPH_WIDTH } from './Root.js';
|
||||
|
||||
export enum LineColor {
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
White,
|
||||
}
|
||||
|
||||
const LINE_COLORS = {
|
||||
[LineColor.Red]: red.red9,
|
||||
[LineColor.Green]: green.green9,
|
||||
[LineColor.Blue]: blue.blue9,
|
||||
[LineColor.White]: slateDark.slate11,
|
||||
};
|
||||
|
||||
export enum LineStyle {
|
||||
|
||||
+16
-14
@@ -1,32 +1,34 @@
|
||||
import { times } from 'lodash';
|
||||
import { theme } from '../../../stitches.config.js';
|
||||
import { MarginProps } from './Root.js';
|
||||
import { MarginInputProps } from './Root.js';
|
||||
|
||||
export enum VerticalMarginAlign {
|
||||
Left,
|
||||
Right,
|
||||
export enum MarginOrientation {
|
||||
Vertical,
|
||||
Horizontal,
|
||||
}
|
||||
|
||||
export interface VerticalMarginProps extends MarginProps {
|
||||
export interface MarginProps extends MarginInputProps {
|
||||
verticalSeparations: number;
|
||||
align?: VerticalMarginAlign;
|
||||
orientation?: MarginOrientation;
|
||||
}
|
||||
|
||||
export function VerticalMargin({
|
||||
export function Margin({
|
||||
verticalSeparations,
|
||||
max,
|
||||
min,
|
||||
suffix,
|
||||
align = VerticalMarginAlign.Left,
|
||||
}: VerticalMarginProps) {
|
||||
precision = 0,
|
||||
orientation = MarginOrientation.Vertical,
|
||||
}: MarginProps) {
|
||||
const isVertical = orientation === MarginOrientation.Vertical;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
width: 32,
|
||||
paddingLeft: isVertical ? 0 : 64,
|
||||
width: isVertical ? 48 : '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems:
|
||||
align === VerticalMarginAlign.Right ? 'flex-end' : 'flex-start',
|
||||
flexDirection: isVertical ? 'column' : 'row-reverse',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
@@ -43,7 +45,7 @@ export function VerticalMargin({
|
||||
((verticalSeparations - (index + 1)) /
|
||||
(verticalSeparations - 1)) +
|
||||
min
|
||||
).toFixed(0)}${suffix ?? ''}`}
|
||||
).toFixed(precision)}${suffix ?? ''}`}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
@@ -1,42 +1,55 @@
|
||||
import { times } from 'lodash';
|
||||
import { ReactNode } from 'react';
|
||||
import { theme } from '../../../stitches.config.js';
|
||||
import { VerticalMargin, VerticalMarginAlign } from './VerticalMargin.js';
|
||||
import { Margin, MarginOrientation } from './Margin.js';
|
||||
|
||||
export const GRAPH_WIDTH = 512;
|
||||
export const GRAPH_WIDTH = 544;
|
||||
export const GRAPH_HEIGHT = 320;
|
||||
|
||||
export interface MarginProps {
|
||||
export interface MarginInputProps {
|
||||
min: number;
|
||||
max: number;
|
||||
suffix?: string;
|
||||
precision?: number;
|
||||
}
|
||||
|
||||
export interface RootProps {
|
||||
children: ReactNode;
|
||||
leftVerticalMargin?: MarginProps;
|
||||
rightVerticalMargin?: MarginProps;
|
||||
verticalSeparations?: number;
|
||||
verticalMargin?: MarginInputProps;
|
||||
horizontalMargin?: MarginInputProps;
|
||||
separations?: number;
|
||||
xMinLabel: string;
|
||||
xMaxLabel: string;
|
||||
}
|
||||
|
||||
export function Root({
|
||||
children,
|
||||
leftVerticalMargin,
|
||||
rightVerticalMargin,
|
||||
verticalSeparations = 5,
|
||||
verticalMargin,
|
||||
horizontalMargin,
|
||||
separations = 5,
|
||||
xMinLabel,
|
||||
xMaxLabel,
|
||||
}: RootProps) {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div
|
||||
style={{
|
||||
paddingLeft: 64,
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
|
||||
{xMinLabel}
|
||||
</span>
|
||||
<span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
|
||||
{xMaxLabel}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 16 }}>
|
||||
{leftVerticalMargin && (
|
||||
<VerticalMargin
|
||||
{...leftVerticalMargin}
|
||||
verticalSeparations={verticalSeparations}
|
||||
/>
|
||||
{verticalMargin && (
|
||||
<Margin {...verticalMargin} verticalSeparations={separations} />
|
||||
)}
|
||||
|
||||
<svg
|
||||
@@ -49,8 +62,8 @@ export function Root({
|
||||
border: theme.borderStyles.nonInteractive,
|
||||
}}
|
||||
>
|
||||
{times(verticalSeparations - 2, (index) => {
|
||||
const y = GRAPH_HEIGHT * ((index + 1) / (verticalSeparations - 1));
|
||||
{times(separations - 2, (index) => {
|
||||
const y = GRAPH_HEIGHT * ((index + 1) / (separations - 1));
|
||||
|
||||
return (
|
||||
<polyline
|
||||
@@ -66,31 +79,15 @@ export function Root({
|
||||
|
||||
{children}
|
||||
</svg>
|
||||
|
||||
{rightVerticalMargin && (
|
||||
<VerticalMargin
|
||||
{...rightVerticalMargin}
|
||||
verticalSeparations={verticalSeparations}
|
||||
align={VerticalMarginAlign.Right}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
paddingLeft: 48,
|
||||
paddingRight: 48,
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
|
||||
{xMinLabel}
|
||||
</span>
|
||||
<span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
|
||||
{xMaxLabel}
|
||||
</span>
|
||||
</div>
|
||||
{horizontalMargin && (
|
||||
<Margin
|
||||
{...horizontalMargin}
|
||||
verticalSeparations={separations}
|
||||
orientation={MarginOrientation.Horizontal}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './components/Line.js';
|
||||
export * from './components/Margin.js';
|
||||
export * from './components/Root.js';
|
||||
export * from './components/VerticalMargin.js';
|
||||
@@ -0,0 +1,38 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { theme } from '../stitches.config.js';
|
||||
|
||||
export enum PoweredByType {
|
||||
BlitzStars,
|
||||
Wargaming,
|
||||
}
|
||||
|
||||
export interface PoweredByProps {
|
||||
type: PoweredByType;
|
||||
footer?: ReactNode;
|
||||
}
|
||||
|
||||
const POWERED_BY_IMAGES: Record<PoweredByType, string> = {
|
||||
[PoweredByType.BlitzStars]:
|
||||
'https://www.blitzstars.com/assets/images/4b4cb591.TankyMcPewpew.png',
|
||||
[PoweredByType.Wargaming]: 'https://i.imgur.com/jADGWm0.png',
|
||||
};
|
||||
|
||||
const POWERED_BY_NAMES: Record<PoweredByType, string> = {
|
||||
[PoweredByType.BlitzStars]: 'BlitzStars',
|
||||
[PoweredByType.Wargaming]: 'Wargaming',
|
||||
};
|
||||
|
||||
export default function PoweredBy({ type, footer }: PoweredByProps) {
|
||||
return (
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<div style={{ display: 'flex' }}>{footer}</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
<img src={POWERED_BY_IMAGES[type]} style={{ height: 16, width: 16 }} />
|
||||
<span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
|
||||
Powered by {POWERED_BY_NAMES[type]}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { theme } from '../stitches.config.js';
|
||||
|
||||
export default function PoweredByBlitzStars() {
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 4, justifyContent: 'flex-end' }}>
|
||||
<img
|
||||
src="https://www.blitzstars.com/assets/images/4b4cb591.TankyMcPewpew.png"
|
||||
style={{ height: 16, width: 16 }}
|
||||
/>
|
||||
<span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
|
||||
Powered by BlitzStars
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { theme } from '../stitches.config.js';
|
||||
|
||||
export default function PoweredByWargaming() {
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 4, justifyContent: 'flex-end' }}>
|
||||
<img
|
||||
src="https://i.imgur.com/jADGWm0.png"
|
||||
style={{ height: 16, width: 16 }}
|
||||
/>
|
||||
<span style={{ color: theme.colors.textLowContrast, fontSize: 16 }}>
|
||||
Powered by Wargaming
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import isDev from '../core/process/isDev.js';
|
||||
import isDev from '../core/node/isDev.js';
|
||||
import { theme } from '../stitches.config.js';
|
||||
|
||||
export interface TitleBarProps {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const CYCLIC_API = 'https://blitzkrieg.cyclic.app';
|
||||
@@ -1,19 +1,7 @@
|
||||
export const BLITZ_SERVERS = {
|
||||
export type BlitzServer = 'com' | 'eu' | 'asia';
|
||||
|
||||
export const BLITZ_SERVERS: Record<BlitzServer, string> = {
|
||||
com: 'North America',
|
||||
eu: 'Europe',
|
||||
asia: 'Asia',
|
||||
};
|
||||
|
||||
export const BLITZ_SERVERS_SHORT = {
|
||||
com: 'NA',
|
||||
eu: 'EU',
|
||||
asia: 'ASIA',
|
||||
};
|
||||
|
||||
export const BLITZ_SERVERS_SHORT_INVERSE = {
|
||||
NA: 'com',
|
||||
EU: 'eu',
|
||||
ASIA: 'asia',
|
||||
};
|
||||
|
||||
export type BlitzServer = keyof typeof BLITZ_SERVERS;
|
||||
@@ -3,7 +3,7 @@ import { AllStats } from '../../types/accountInfo.js';
|
||||
/**
|
||||
* Formula from https://web.archive.org/web/20190105064817/http://wiki.wnefficiency.net/pages/WN8
|
||||
*/
|
||||
export default function getWN8(expected: AllStats, average: AllStats) {
|
||||
export default function calculateWN8(expected: AllStats, average: AllStats) {
|
||||
const avgDmg = average.damage_dealt / average.battles;
|
||||
const avgSpot = average.spotted / average.battles;
|
||||
const avgFrag = average.frags / average.battles;
|
||||
@@ -1,23 +1,19 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { serverAndIdPattern } from '../options/resolvePlayer.js';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
import listClansPanServer from './listClansPanServer.js';
|
||||
import { serverAndIdPattern } from '../discord/resolvePlayerFromCommand.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import listClans from './listClans.js';
|
||||
|
||||
export default async function getBlitzClan(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
clan: string,
|
||||
) {
|
||||
export default async function getBlitzClan(clan: string) {
|
||||
if (serverAndIdPattern.test(clan)) {
|
||||
const [server, accountId] = clan.split('/');
|
||||
return { server: server as BlitzServer, id: Number(accountId) };
|
||||
} else {
|
||||
const accounts = await listClansPanServer(clan);
|
||||
const accounts = await listClans(clan);
|
||||
|
||||
if (accounts[0]) {
|
||||
return { server: accounts[0].server, id: accounts[0].clan_id };
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Could not find clan',
|
||||
`I couldn't find clan \`${clan}\`. Try selecting a username from the search result.`,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js';
|
||||
import { TanksStats } from '../../types/tanksStats.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export default async function getTankStats(server: BlitzServer, id: number) {
|
||||
@@ -10,7 +10,7 @@ export default async function getTankStats(server: BlitzServer, id: number) {
|
||||
);
|
||||
|
||||
if (tankStats[id] === null) {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'No tank stats available',
|
||||
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${BLITZ_SERVERS[server]} server.`,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { WargamingResponse } from '../../types/wargamingResponse.js';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
|
||||
export type WargamingResponse<Data extends object> =
|
||||
| {
|
||||
status: 'error';
|
||||
error: { field: string; message: string; code: 402; value: null };
|
||||
}
|
||||
| {
|
||||
status: 'ok';
|
||||
data: Data;
|
||||
};
|
||||
|
||||
export default async function getWargamingResponse<Data extends object>(
|
||||
url: string,
|
||||
@@ -12,7 +21,7 @@ export default async function getWargamingResponse<Data extends object>(
|
||||
if (parsed.status === 'ok') {
|
||||
return parsed.data;
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
`Wargaming response error status:"${parsed.status}"`,
|
||||
`Message: "${parsed.error.message}"\nURL: "${url}"`,
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { Clan, ClanList } from '../../types/clanList.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export type ClanListWithServer = (Clan & {
|
||||
server: 'com' | 'eu' | 'asia';
|
||||
})[];
|
||||
|
||||
export default async function listClansPanServer(search: string, limit = 9) {
|
||||
export default async function listClans(search: string, limit = 9) {
|
||||
const trimmed = search.trim();
|
||||
if (trimmed.length < 3 && trimmed.length > 100) return [];
|
||||
const normalizedLimit = Math.round(limit / 3);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
import { Account, AccountList } from '../../types/accountList.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import getWargamingResponse from './getWargamingResponse.js';
|
||||
|
||||
export type AccountListWithServer = (Account & {
|
||||
@@ -10,7 +10,7 @@ export type AccountListWithServer = (Account & {
|
||||
export const usernamePattern = /^[a-zA-Z0-9_]{3,24}$/;
|
||||
export const usernamePatternWithoutPosition = /[a-zA-Z0-9_]{3,24}/;
|
||||
|
||||
export default async function listAccountsPanServer(search: string, limit = 9) {
|
||||
export default async function listPlayers(search: string, limit = 9) {
|
||||
const trimmedSearch = search.trim();
|
||||
const normalizedLimit = Math.round(limit / 3);
|
||||
const encodedSearch = encodeURIComponent(trimmedSearch);
|
||||
@@ -1,15 +1,15 @@
|
||||
import { go } from 'fuzzysort';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
import throwError from '../node/throwError.js';
|
||||
import { TANKS, tankopedia } from './tankopedia.js';
|
||||
|
||||
export default function resolveTankId(tank: string) {
|
||||
const number = Number(tank);
|
||||
export default async function resolveTankId(tank: string) {
|
||||
const number = parseInt(tank);
|
||||
|
||||
if (Number.isNaN(number)) {
|
||||
const searchResult = go(tank, TANKS, { keys: ['name'], limit: 1 });
|
||||
const searchResult = go(tank, await TANKS, { keys: ['name'], limit: 1 });
|
||||
|
||||
if (searchResult.length === 0) {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the name "${tank}".`,
|
||||
);
|
||||
@@ -17,10 +17,10 @@ export default function resolveTankId(tank: string) {
|
||||
return searchResult[0].obj.tank_id;
|
||||
}
|
||||
} else {
|
||||
if (tankopedia[number]) {
|
||||
if ((await tankopedia)[number]) {
|
||||
return number;
|
||||
} else {
|
||||
throw errorWithCause(
|
||||
throw throwError(
|
||||
'Tank not found',
|
||||
`Could not find tank by the ID "${number}".`,
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tankopedia } from './tankopedia.js';
|
||||
|
||||
export default function resolveTankName(tankId: number) {
|
||||
const tankopediaName = tankopedia[tankId].name;
|
||||
export default async function resolveTankName(tankId: number) {
|
||||
const tankopediaName = (await tankopedia)[tankId].name;
|
||||
return tankopediaName ? tankopediaName : `Unknown Tank ${tankId}`;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AllStats } from '../../types/accountInfo.js';
|
||||
import { emptyAllStats } from '../blitzstars/getTankStatsOverTime.js';
|
||||
import { emptyAllStats } from '../blitzstars/getTankStatsDiffed.js';
|
||||
|
||||
export default function sumStats(allStatsCollection: AllStats[]) {
|
||||
return allStatsCollection.reduce((accumulated, current) => {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { WargamingResponse } from '../../types/wargamingResponse.js';
|
||||
|
||||
export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank';
|
||||
|
||||
export interface TankopediaEntry {
|
||||
@@ -18,30 +16,22 @@ export interface Tankopedia {
|
||||
[id: number]: TankopediaEntry;
|
||||
}
|
||||
|
||||
export const tankopedia: Tankopedia = {};
|
||||
export const TANK_IDS: number[] = [];
|
||||
export const TANKS: TankopediaEntry[] = [];
|
||||
export const TANK_NAMES: string[] = [];
|
||||
|
||||
console.log('Caching tankopedia...');
|
||||
fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
.then(
|
||||
(response) =>
|
||||
response.json() as Promise<
|
||||
WargamingResponse<Tankopedia> & { status: 'ok' }
|
||||
>,
|
||||
)
|
||||
.then((wargamingResponse) => {
|
||||
Object.assign(tankopedia, wargamingResponse.data);
|
||||
Object.entries(tankopedia).forEach(([idString, entry]) => {
|
||||
const id = Number(idString);
|
||||
|
||||
TANK_IDS.push(id);
|
||||
TANKS.push(entry);
|
||||
TANK_NAMES.push(entry.name);
|
||||
}),
|
||||
console.log('Cached tankopedia');
|
||||
export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
.then((response) => response.json())
|
||||
.then((wrapperTankopedia) => {
|
||||
console.log('Tankopedia cached');
|
||||
return (wrapperTankopedia as { data: Tankopedia }).data;
|
||||
});
|
||||
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
||||
});
|
||||
export const TANKS = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||
resolve((await entries).map((entry) => entry));
|
||||
});
|
||||
export const TANK_NAMES = new Promise<string[]>(async (resolve) => {
|
||||
resolve((await entries).map(({ name }) => name));
|
||||
});
|
||||
|
||||
export const TANK_ICONS: Record<TankType, string> = {
|
||||
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import {
|
||||
CacheType,
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
} from 'discord.js';
|
||||
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||
import { handleError } from '../../events/error.js';
|
||||
import { client } from '../../index.js';
|
||||
|
||||
export default async function wargamingError(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
error: Error,
|
||||
command: string,
|
||||
) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(`${client.user?.username} ran into an issue`)
|
||||
.setDescription('Wargaming returned an error. Please try again later.'),
|
||||
],
|
||||
});
|
||||
|
||||
console.log(`Wargaming returned an error`);
|
||||
handleError(error, command);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import {
|
||||
CacheType,
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
} from 'discord.js';
|
||||
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||
import { handleError } from '../../events/error.js';
|
||||
import { client } from '../../index.js';
|
||||
|
||||
export default async function blitzStarsError(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
error: Error,
|
||||
command: string,
|
||||
) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(`${client.user?.username} ran into an issue`)
|
||||
.setDescription(
|
||||
'BlitzStars returned an error. Please try again later.',
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
console.log(`BlitzStars returned an error`);
|
||||
handleError(error, command);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
|
||||
export default function blitzStarsLinks(server: BlitzServer, nickname: string) {
|
||||
return `[View full stats](https://www.blitzstars.com/player/${server}/${nickname}) • [Support BlitzStars](https://www.blitzstars.com/supporters)`;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Period } from '../options/addPeriodSubCommands.js';
|
||||
import { Period } from '../discord/addPeriodSubCommands.js';
|
||||
import getTimeDaysAgo from './getTimeDaysAgo.js';
|
||||
|
||||
export default function getPeriodStart(period: Exclude<Period, 'custom'>) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
getHistoriesDefaultOptions,
|
||||
} from '../../types/histories.js';
|
||||
import getWargamingResponse from '../blitz/getWargamingResponse.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../process/args.js';
|
||||
import { emptyAllStats } from './getTankStatsOverTime.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../node/arguments.js';
|
||||
import { emptyAllStats } from './getTankStatsDiffed.js';
|
||||
|
||||
export interface PlayerHistoryRaw {
|
||||
clan: { clan_id: number; name: string; tag: string };
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
getHistoriesDefaultOptions,
|
||||
} from '../../types/histories.js';
|
||||
import getTankStats from '../blitz/getTankStats.js';
|
||||
import { emptyAllStats } from './getTankStatsOverTime.js';
|
||||
import { emptyAllStats } from './getTankStatsDiffed.js';
|
||||
|
||||
export interface TankHistory extends History {
|
||||
tank_id: number;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ export const emptyTankHistoryNode: TankHistoryRaw = {
|
||||
all: emptyAllStats,
|
||||
};
|
||||
|
||||
export default async function getTankStatsOverTime(
|
||||
export default async function getTankStatsDiffed(
|
||||
server: BlitzServer,
|
||||
id: number,
|
||||
start: number,
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function getTimeDaysAgo(period: number) {
|
||||
export default function getTimeDaysAgo(daysAgo: number) {
|
||||
const now = new Date();
|
||||
now.setHours(5, 0, 0, 0);
|
||||
|
||||
@@ -6,7 +6,7 @@ export default function getTimeDaysAgo(period: number) {
|
||||
if (now.getTime() > Date.now()) now.setDate(now.getDate() - 1);
|
||||
|
||||
// subtract the period number of days from now
|
||||
now.setDate(now.getDate() - period);
|
||||
now.setDate(now.getDate() - daysAgo);
|
||||
|
||||
return now.getTime() / 1000;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
export default function last5AM() {
|
||||
const fiveAM = new Date();
|
||||
fiveAM.setHours(5, 0, 0, 0); // Set the time to 5:00 AM today
|
||||
|
||||
if (fiveAM > new Date()) {
|
||||
// If it's now before 5:00 AM, go back one day
|
||||
fiveAM.setDate(fiveAM.getDate() - 1);
|
||||
}
|
||||
|
||||
return fiveAM;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import sumStats from '../blitz/sumStats.js';
|
||||
import { emptyAllStats } from './getTankStatsOverTime.js';
|
||||
import { emptyAllStats } from './getTankStatsDiffed.js';
|
||||
import { tankAverages } from './tankAverages.js';
|
||||
|
||||
console.log('Calculating player average...');
|
||||
export const playerAverage = Object.entries(tankAverages).reduce(
|
||||
export const playerAverage = Object.entries(await tankAverages).reduce(
|
||||
(accumulator, [, tankAverage]) => {
|
||||
return sumStats([accumulator, tankAverage.all]);
|
||||
},
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
|
||||
export default function poweredByBlitzStars(embed: EmbedBuilder) {
|
||||
return embed.setTimestamp().setFooter({
|
||||
text: 'Powered by BlitzStars',
|
||||
iconURL: 'https://www.blitzstars.com/assets/images/TankyMcPewpew.png',
|
||||
});
|
||||
}
|
||||
@@ -78,14 +78,24 @@ export interface IndividualTankAverage {
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
export const tankAverages: Record<number, IndividualTankAverage> = {};
|
||||
export type TankAverages = Record<number, IndividualTankAverage>;
|
||||
|
||||
console.log('Caching tank averages...');
|
||||
fetch('https://www.blitzstars.com/api/tankaverages.json')
|
||||
.then((response) => response.json() as Promise<IndividualTankAverage[]>)
|
||||
export const tankAverages = fetch(
|
||||
'https://www.blitzstars.com/api/tankaverages.json',
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((individualTankAverages) => {
|
||||
individualTankAverages.forEach((individualTankAverage) => {
|
||||
tankAverages[individualTankAverage.tank_id] = individualTankAverage;
|
||||
});
|
||||
const partialTankAverages: TankAverages = {};
|
||||
|
||||
(individualTankAverages as IndividualTankAverage[]).forEach(
|
||||
(individualTankAverage) => {
|
||||
partialTankAverages[individualTankAverage.tank_id] =
|
||||
individualTankAverage;
|
||||
},
|
||||
);
|
||||
|
||||
console.log('Tank averages cached');
|
||||
|
||||
return partialTankAverages;
|
||||
});
|
||||
File renamed without changes.
+1
-10
@@ -2,19 +2,10 @@ import {
|
||||
SlashCommandSubcommandBuilder,
|
||||
SlashCommandSubcommandGroupBuilder,
|
||||
} from 'discord.js';
|
||||
import { PERIOD_NAMES } from './resolvePeriod.js';
|
||||
import { PERIOD_NAMES } from '../discord/resolvePeriodFromCommand.js';
|
||||
|
||||
export type Period = 'today' | '30' | '60' | '90' | 'career' | 'custom';
|
||||
|
||||
export const RELATIVE_PERIOD_NAMES: Record<Period, string> = {
|
||||
today: 'A day ago',
|
||||
30: '30 days ago',
|
||||
60: '60 days ago',
|
||||
90: '90 days ago',
|
||||
career: 'Extent of data',
|
||||
custom: 'Custom period',
|
||||
};
|
||||
|
||||
export default function addPeriodSubCommands(
|
||||
option: SlashCommandSubcommandGroupBuilder,
|
||||
extra: (
|
||||
Loaded 100 of 161 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user