Skip to content

Commit

Permalink
Merge pull request #25 from tresabhi/1.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tresabhi authored Aug 23, 2023
2 parents 8175aa8 + cb5347c commit 28172f7
Show file tree
Hide file tree
Showing 27 changed files with 1,600 additions and 481 deletions.
29 changes: 21 additions & 8 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DefaultTheme, defineConfig } from 'vitepress';
import { compareVersions } from 'compare-versions';
import { readdirSync } from 'fs';
import { parse } from 'path';
import { defineConfig } from 'vitepress';
import { getSidebar } from 'vitepress-plugin-auto-sidebar';

export default defineConfig({
Expand All @@ -9,17 +12,27 @@ export default defineConfig({
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Examples', link: '/markdown-examples' },
{ text: 'Guide', link: '/guide/about' },
],

sidebar: getSidebar({
collapsed: false,
contentDirs: ['guide', 'legal', 'changelogs'],
contentRoot: '/docs/',
}) as DefaultTheme.Sidebar,
sidebar: [
...getSidebar({
collapsed: false,
contentDirs: ['guide', 'legal'],
contentRoot: '/docs/',
}),

{
text: 'Changelogs',
items: readdirSync('./docs/changelogs')
.map((file) => parse(file).name)
.sort(compareVersions)
.map((name) => ({ text: name, link: `/changelogs/${name}.html` })),
},
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
{ icon: 'github', link: 'https://github.com/tresabhi/blitzkrieg' },
],
},
});
29 changes: 29 additions & 0 deletions docs/changelogs/1.12.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Blitzkrieg 1.12.2

A much needed room service is here!

## Changes

- Tier selection is now easier
- Tier options across all commands have been unified to a single style
- Tiers are now sorted from `10` to `1`
- Tiers now show up in the format `Tier {tier_number} - {tier_roman_numeral}` (example: `Tier 8 - VIII`)
- Removed powered by footer as links are provided regardless
- Changed invite instructions to instead use application directory

## Fixes

- Guide link on the website is now fixed
- Versions now show up in the correct order in the navigation bar
- Added Blitzkrieg's GitHub link instead of the default Vitepress
- Changed examples to guide in the navigation bar
- Clan name and icon now show up with multi-tank filters
- Removed a random `console.log`

## Technical Changes

- Added `knip`
- Removed a lot of unused files and dependencies
- Updated all dependencies to their latest
- Code split `bot.ts`
- `client` and `octokit` now reside separately
9 changes: 1 addition & 8 deletions docs/guide/invite.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# 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.
Go to [application directory for Blitzkrieg](https://discord.com/application-directory/1097673957865443370) and click "Add to Server." Voila! You're ready to go.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hero:
link: guide/install
- theme: alt
text: Guide
link: /guide
link: /guide/about

features:
- title: Clean and Efficient UI
Expand Down
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,39 @@
"publish:ratingsleaderboard": "vite-node --script scripts/buildRatingsLeaderboard --publish",
"zip": "zip -r dist.zip dist",
"lint": "npx tsc",
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\""
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
"knip": "knip",
"update": "yarn upgrade --latest"
},
"license": "MIT",
"dependencies": {
"@octokit/rest": "^20.0.1",
"@radix-ui/colors": "^0.1.8",
"@radix-ui/colors": "^2.1.0",
"@resvg/resvg-js": "^2.4.1",
"bepaint": "^0.1.0-beta.3",
"discord.js": "^14.12.0",
"esbuild": "^0.18.10",
"escape-html": "^1.0.3",
"discord.js": "^14.13.0",
"esbuild": "^0.19.2",
"express": "^4.18.2",
"false": "^0.0.4",
"fuzzysort": "^2.0.4",
"lodash": "^4.17.21",
"markdown-escape": "^2.0.0",
"react": "^18.2.0",
"satori": "^0.9.1",
"vite-node": "^0.33.0",
"satori": "^0.10.3",
"vite-node": "^0.34.2",
"vitepress-plugin-auto-sidebar": "^1.1.0"
},
"devDependencies": {
"@total-typescript/ts-reset": "^0.4.2",
"@total-typescript/ts-reset": "^0.5.1",
"@types/escape-html": "^1.0.2",
"@types/express": "^4.17.17",
"@types/lodash": "^4.14.195",
"@types/lodash": "^4.14.197",
"@types/markdown-escape": "^1.1.0",
"@types/node": "^20.2.1",
"@types/react": "^18.2.7",
"prettier": "^3.0.0",
"@types/node": "^20.5.3",
"@types/react": "^18.2.21",
"compare-versions": "^6.1.0",
"knip": "^2.19.9",
"prettier": "^3.0.2",
"typescript": "^5.0.4",
"vitepress": "^1.0.0-beta.3"
"vitepress": "^1.0.0-rc.4"
}
}
15 changes: 1 addition & 14 deletions src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import { Octokit } from '@octokit/rest';
import { Client, GatewayIntentBits } from 'discord.js';
import { client } from './core/discord/client';
import { secrets } from './core/node/secrets';
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],
})
.on('ready', ready)
.on('guildMemberAdd', guildMemberAdd)
.on('interactionCreate', interactionCreate);

export const octokit = new Octokit({ auth: secrets.GH_TOKEN });

registerErrorHandlers();
client.login(secrets.DISCORD_TOKEN);
2 changes: 1 addition & 1 deletion src/commands/debug.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SlashCommandBuilder } from 'discord.js';
import packageJSON from '../../package.json' assert { type: 'json' };
import { client } from '../bot';
import { tankopedia } from '../core/blitz/tankopedia';
import { tankAverages } from '../core/blitzstars/tankAverages';
import { client } from '../core/discord/client';
import embedInfo from '../core/discord/embedInfo';
import markdownTable from '../core/discord/markdownTable';
import getClientId from '../core/node/getClientId';
Expand Down
4 changes: 3 additions & 1 deletion src/commands/fullStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const fullStatsCommand = new Promise<CommandRegistryRaw>(
)
)[player.id];

const tierOption = interaction.options.getString('tier');

return [
await fullStats(
commandGroup,
Expand All @@ -74,7 +76,7 @@ export const fullStatsCommand = new Promise<CommandRegistryRaw>(
'tank-type':
interaction.options.getString('tank-type') ?? undefined,
nation: interaction.options.getString('nation') ?? undefined,
tier: interaction.options.getInteger('tier') ?? undefined,
tier: tierOption ? parseInt(tierOption) : undefined,
'tree-type': (interaction.options.getString('tree-type') ??
undefined) as TreeTypeString | undefined,
} satisfies Partial<MultiTankFilters>)
Expand Down
3 changes: 0 additions & 3 deletions src/commands/inactive.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SlashCommandBuilder } from 'discord.js';
import GenericStats from '../components/GenericStats';
import NoData, { NoDataType } from '../components/NoData';
import PoweredBy, { PoweredByType } from '../components/PoweredBy';
import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import getBlitzClan from '../core/blitz/getBlitzClan';
Expand Down Expand Up @@ -74,8 +73,6 @@ export const inactiveCommand: CommandRegistry = {

{!hasInactiveMembers && <NoData type={NoDataType.PlayersInPeriod} />}
{hasInactiveMembers && <GenericStats stats={inactive} />}

<PoweredBy type={PoweredByType.Wargaming} />
</Wrapper>
);
},
Expand Down
23 changes: 2 additions & 21 deletions src/commands/ownedTanks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SlashCommandBuilder } from 'discord.js';
import NoData, { NoDataType } from '../components/NoData';
import PoweredBy, { PoweredByType } from '../components/PoweredBy';
import * as Tanks from '../components/Tanks';
import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
Expand All @@ -15,6 +14,7 @@ import {
tankopedia,
tankopediaInfo,
} from '../core/blitz/tankopedia';
import addTierChoices from '../core/discord/addTierChoices';
import addUsernameChoices from '../core/discord/addUsernameChoices';
import autocompleteUsername from '../core/discord/autocompleteUsername';
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
Expand Down Expand Up @@ -52,24 +52,7 @@ export const ownedTanksCommand: CommandRegistry = {
command: new SlashCommandBuilder()
.setName('owned-tanks')
.setDescription("Shows a player's owned tanks")
.addStringOption((option) =>
option
.setName('tier')
.setDescription('The tier you want to see')
.setChoices(
{ name: 'Tier I (1)', value: '1' },
{ name: 'Tier II (2)', value: '2' },
{ name: 'Tier III (3)', value: '3' },
{ name: 'Tier IV (4)', value: '4' },
{ name: 'Tier V (5)', value: '5' },
{ name: 'Tier VI (6)', value: '6' },
{ name: 'Tier VII (7)', value: '7' },
{ name: 'Tier VIII (8)', value: '8' },
{ name: 'Tier IX (9)', value: '9' },
{ name: 'Tier X (10)', value: '10' },
)
.setRequired(true),
)
.addStringOption(addTierChoices)
.addStringOption(addUsernameChoices),

async handler(interaction) {
Expand Down Expand Up @@ -170,8 +153,6 @@ export const ownedTanksCommand: CommandRegistry = {
);
}),
))}

<PoweredBy type={PoweredByType.Wargaming} />
</Wrapper>
);
},
Expand Down
4 changes: 3 additions & 1 deletion src/commands/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const statsCommand = new Promise<CommandRegistryRaw>(async (resolve) => {
)
)[player.id];

const tierOption = interaction.options.getString('tier');

return [
await stats(
commandGroup,
Expand All @@ -72,7 +74,7 @@ export const statsCommand = new Promise<CommandRegistryRaw>(async (resolve) => {
'tank-type':
interaction.options.getString('tank-type') ?? undefined,
nation: interaction.options.getString('nation') ?? undefined,
tier: interaction.options.getInteger('tier') ?? undefined,
tier: tierOption ? parseInt(tierOption) : undefined,
'tree-type': (interaction.options.getString('tree-type') ??
undefined) as TreeTypeString | undefined,
} satisfies Partial<MultiTankFilters>)
Expand Down
43 changes: 0 additions & 43 deletions src/components/PoweredBy.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/core/blitz/diffStats.ts

This file was deleted.

32 changes: 32 additions & 0 deletions src/core/blitz/numberToRomanNumeral.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Thanks, August!
* https://stackoverflow.com/a/41358305/12294756
*/
const ROMAN = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
I: 1,
};
const ROMAN_KEYS = Object.keys(ROMAN) as (keyof typeof ROMAN)[];

export default function numberToRomanNumeral(value: number) {
let string = '';

ROMAN_KEYS.forEach((index) => {
const part = Math.floor(value / ROMAN[index]);
value -= part * ROMAN[index];
string += index.repeat(part);
});

return string;
}
Loading

0 comments on commit 28172f7

Please sign in to comment.