Skip to content

Commit

Permalink
Merge pull request #19 from tresabhi/1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tresabhi authored Jul 12, 2023
2 parents aa8115d + 186d45e commit 098e6c0
Show file tree
Hide file tree
Showing 124 changed files with 1,323 additions and 793 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dist.zip
commands.txt
/test.*
/docs/.vitepress/dist
/docs/.vitepress/cache
/docs/.vitepress/cache
servers.csv
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"cleandist",
"customperiod",
"Everytime",
"fullstats",
"fuzzysort",
"kranvagn",
"outfile",
Expand Down
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
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,
- 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
- 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
- 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
- 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
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ 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
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
Expand Down
12 changes: 6 additions & 6 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// https://vitepress.dev/guide/custom-theme
import { h } from 'vue'
import Theme from 'vitepress/theme'
import './style.css'
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 }) {
// ...
}
}
},
};
3 changes: 1 addition & 2 deletions docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Colors
* -------------------------------------------------------------------------- */

:root {
:root {
--vp-c-brand: #646cff;
--vp-c-brand-light: #747bff;
--vp-c-brand-lighter: #9499ff;
Expand Down Expand Up @@ -88,4 +88,3 @@
.DocSearch {
--docsearch-primary-color: var(--vp-c-brand) !important;
}

37 changes: 37 additions & 0 deletions docs/changelogs/1.10.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Blitzkrieg 1.10.0

This update addresses many readability issues that users have reported over time.

## Changes

- `/ownedtanks`
- Tanks are now displayed in two columns
- Collector and premium tanks now have their own colors
- Tank types are also displayed
- A stylistic image of the tank is also displayed for each tank to the right
- `/fullstats`
- Was previously called `/statsfull`; this was changed to avoid the clutter that would show up when searching for `/stats`
- Added four catagories in which all the stats are sorted into
- Catagories now have backgrounds to compartmentalize them
- `/evolution`
- Gave the axis markings a high contrast color
- Added a label for the x axis affirming that it is plotted over the number of battles
- `/today`
- Added a border to all the rows to compartmentalize them
- This command can now generate embeds too
- Removed survivability
- Added a limit option to cut off after a certain number of tanks played (this is mainly intended to be used by streamers to limit the content of the embeds)
- Tanks are now displayed in order of the most recent battle
- `/help`
- A significant amount of subcommands were added
- These new subcommands now return normal Discord messages instead of embeds in favor of readability
- The contents of the replies are directly fetched from the Blitzkrieg documentation
- Time zones
- What is considered a "day's worth of battles" has been adjusted as the "reset time" was the same for all Blitz servers
- The reset time is now dependent on the server of the player
- Use `/help timezones` to learn more

## Technical Changes

- All themes have been merged to leverage Bepaint's suffixes
- Switched to Node module resolution
2 changes: 1 addition & 1 deletion docs/changelogs/1.9.5.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Blitzkrieg 1.9.5

Hopefully this is the last round of fixes for Blitzkrieg `1.9``.
Hopefully this is the last round of fixes for Blitzkrieg `1.9`.

## Fixes

Expand Down
10 changes: 10 additions & 0 deletions docs/guide/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# About

Blitzkrieg is a multipurpose bot for anything and everything World of Tanks Blitz.

- Track statistics
- Find inactive players in a clan
- Lookup owned tanks
- Create embeds for streams
- Track a player/tanks statistical evolution
- ...and a variety of other similar things
23 changes: 23 additions & 0 deletions docs/guide/embeds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Embeds

Embeds are generated by a few commands as a URL that can be loaded in a browser/streaming software.

## Creating Embeds

1. Use a command of your liking (for example, `/stats`).
2. Customize the command however you like and the URL generated for the embed will match your needs.
3. Send the command and when the bot is "done thinking," an "Embed" button will appear below the bot's reply.

## Using Embeds in Streaming Softwares

1. Click on the "Embed" button.
2. Copy the URL from your browser.
3. Paste the URL into a Browser Source.
4. Set the refresh rate/FPS to something very low like `0.0167` (that's 1 frame every 60 seconds).

## How Embeds Behave

- They load like any normal website albeit with a significant delay.
- They auto refresh every `60s`.
- All embeds and images generated by Blitzkrieg have a width of `640px` but the height varies and must be found manually through trial and error.
- It's okay to have a Browser Source that has a height larger than needed as Blitzkrieg embeds are transparent.
10 changes: 10 additions & 0 deletions docs/guide/invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Inviting the Bot

It's quite simple really. Just follow the steps below:

1. Join a Discord server that already has Blitzkrieg installed or [the official Discord Server](https://discord.gg/nDt7AjGJQH).
2. Click on the bot's profile.
3. Click the "Add to Server" button under the bot's name and ID.
4. Select what server you want it in and see what permissions you seem fit for the bot.

Voila! You're ready to go.
9 changes: 9 additions & 0 deletions docs/guide/timezones.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Timezones

What is considered a "day's worth of games" is determined by the reset time. The reset time is generally at midnight everyday after which newer games are counted towards the next day. Reset times vary from region to region:

- North America: `UTC-5:00` (Central North American Time midnight)
- Europe: `UTC+1:00` (Central European Time midnight)
- Asia: `UTC+7:00` (Central Asia Standard Time midnight)

**Reset times are different from Blitz Stars** (Blitz Stars resets at 5:00 am locally relative to the user opening their website). Inconsistencies with Blitz Stars only occur with sleep-deprived players and players who play in the wrong region.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blitzkrieg",
"version": "1.9.4",
"version": "1.10.0",
"description": "",
"main": "src/server.ts",
"type": "module",
Expand All @@ -16,7 +16,8 @@
"start:server": "node --enable-source-maps --trace-warnings dist/server.cjs",
"host:docs": "vitepress preview docs",
"zip": "zip -r dist.zip dist",
"lint": "npx tsc"
"lint": "npx tsc",
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\""
},
"license": "MIT",
"dependencies": {
Expand All @@ -42,6 +43,7 @@
"@types/markdown-escape": "^1.1.0",
"@types/node": "^20.2.1",
"@types/react": "^18.2.7",
"prettier": "^3.0.0",
"typescript": "^5.0.4",
"vitepress": "^1.0.0-beta.3"
}
Expand Down
10 changes: 5 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Client, GatewayIntentBits } from 'discord.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/index.js';
import ready from './events/ready.js';
import { DISCORD_TOKEN } from './core/node/arguments';
import { registerErrorHandlers } from './events/error';
import guildMemberAdd from './events/guildMemberAdd';
import interactionCreate from './events/interactionCreate';
import ready from './events/ready';

export const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
Expand Down
16 changes: 8 additions & 8 deletions src/commands/debug.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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 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';
import { client } from '../bot';
import { tankopedia } from '../core/blitz/tankopedia';
import { tankAverages } from '../core/blitzstars/tankAverages';
import embedInfo from '../core/discord/embedInfo';
import markdownTable from '../core/discord/markdownTable';
import getClientId from '../core/node/getClientId';
import { CommandRegistry } from '../events/interactionCreate';

const executionStart = new Date().getTime();

export const debugCommand: CommandRegistry = {
inProduction: true,
inDevelopment: true,
inDevelopment: false,
inPublic: true,

command: new SlashCommandBuilder()
Expand Down
46 changes: 23 additions & 23 deletions src/commands/eligible.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { SlashCommandBuilder } from 'discord.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 getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js';
import { tankAverages } from '../core/blitzstars/tankAverages.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';
import calculateWN8 from '../core/blitz/calculateWN8';
import getWargamingResponse from '../core/blitz/getWargamingResponse';
import sumStats from '../core/blitz/sumStats';
import { tankopedia } from '../core/blitz/tankopedia';
import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
import getPeriodNow from '../core/blitzstars/getPeriodNow';
import getTimeDaysAgo from '../core/blitzstars/getTimeDaysAgo';
import { tankAverages } from '../core/blitzstars/tankAverages';
import addUsernameChoices from '../core/discord/addUsernameChoices';
import embedNegative from '../core/discord/embedNegative';
import embedPositive from '../core/discord/embedPositive';
import markdownTable, { TableInput } from '../core/discord/markdownTable';
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
import { WARGAMING_APPLICATION_ID } from '../core/node/arguments';
import { CommandRegistry } from '../events/interactionCreate';
import { AccountInfo } from '../types/accountInfo';
import { PossiblyPromise } from '../types/possiblyPromise';

export type SkilledClan = 'SKLLD' | 'SMRI';

Expand All @@ -26,7 +26,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {

export const eligibleCommand: CommandRegistry = {
inProduction: true,
inDevelopment: true,
inDevelopment: false,
inPublic: false,

command: new SlashCommandBuilder()
Expand Down Expand Up @@ -59,13 +59,13 @@ export const eligibleCommand: CommandRegistry = {
let body = '';

if (clan === 'SKLLD') {
const tankStatsOverTime = await getTankStatsDiffed(
const { diffed } = await getDiffedTankStats(
server,
id,
getPeriodStart('30'),
getTimeDaysAgo(server, 30),
getPeriodNow(),
);
const entries = Object.entries(tankStatsOverTime);
const entries = Object.entries(diffed);
const stats = sumStats(entries.map(([, stats]) => stats));
const averageTier =
(await entries.reduce<PossiblyPromise<number>>(
Expand Down Expand Up @@ -116,7 +116,7 @@ export const eligibleCommand: CommandRegistry = {
const tankId = parseInt(tankIdString);

if ((await tankopedia)[tankId]?.tier === 10) {
const tankStats = tankStatsOverTime[tankId];
const tankStats = diffed[tankId];
return (await accumulator) + tankStats.damage_dealt;
} else return accumulator;
},
Expand All @@ -127,7 +127,7 @@ export const eligibleCommand: CommandRegistry = {
const tankId = parseInt(tankIdString);

if ((await tankopedia)[tankId]?.tier === 10) {
const tankStats = tankStatsOverTime[tankId];
const tankStats = diffed[tankId];
return (await accumulator) + tankStats.battles;
} else return accumulator;
},
Expand Down
Loading

0 comments on commit 098e6c0

Please sign in to comment.