From c0ac935652205f31ccc6239ca8494b94a986fd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:36:40 -0600 Subject: [PATCH 01/14] feat: remove manual asia leaderboard trigger --- .github/workflows/cd-asia-ratings-latest.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml index b3c1a2598..85ba74d8f 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -2,8 +2,7 @@ name: CD Asia Ratings Latest on: schedule: - - cron: "0 0 * * *" - workflow_dispatch: + - cron: '0 0 * * *' jobs: host: @@ -17,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -25,7 +24,7 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies From 1afe860e76577fc0ec246d07df9f6fdaee0e98df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:38:04 -0600 Subject: [PATCH 02/14] feat: change workflow file name to midnight --- ...asia-ratings-leaderboards.yml => cd-asia-ratings-midnight.yml} | 0 ...{cd-eu-ratings-leaderboards.yml => cd-eu-ratings-midnight.yml} | 0 ...{cd-na-ratings-leaderboards.yml => cd-na-ratings-midnight.yml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cd-asia-ratings-leaderboards.yml => cd-asia-ratings-midnight.yml} (100%) rename .github/workflows/{cd-eu-ratings-leaderboards.yml => cd-eu-ratings-midnight.yml} (100%) rename .github/workflows/{cd-na-ratings-leaderboards.yml => cd-na-ratings-midnight.yml} (100%) diff --git a/.github/workflows/cd-asia-ratings-leaderboards.yml b/.github/workflows/cd-asia-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-asia-ratings-leaderboards.yml rename to .github/workflows/cd-asia-ratings-midnight.yml diff --git a/.github/workflows/cd-eu-ratings-leaderboards.yml b/.github/workflows/cd-eu-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-eu-ratings-leaderboards.yml rename to .github/workflows/cd-eu-ratings-midnight.yml diff --git a/.github/workflows/cd-na-ratings-leaderboards.yml b/.github/workflows/cd-na-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-na-ratings-leaderboards.yml rename to .github/workflows/cd-na-ratings-midnight.yml From 06cbcc23395376d8a505672f35cabe5fa40e9607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:39:04 -0600 Subject: [PATCH 03/14] fix: "Midnight" in name --- .github/workflows/cd-asia-ratings-midnight.yml | 2 +- .github/workflows/cd-eu-ratings-midnight.yml | 2 +- .github/workflows/cd-na-ratings-midnight.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-asia-ratings-midnight.yml index 2462e4601..ebad9ad1a 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-asia-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD Asia Ratings Leaderboards +name: CD Asia Ratings Midnight on: schedule: diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-eu-ratings-midnight.yml index c026c483d..da778b527 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-eu-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD Europe Ratings Leaderboards +name: CD Europe Ratings Midnight on: schedule: diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml index 414e143a3..1426f7c31 100644 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ b/.github/workflows/cd-na-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD North America Ratings Leaderboards +name: CD North America Ratings Midnight on: schedule: From 55729c5eda0a68045c1a4f546d2f877e20cc32bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:46:56 -0600 Subject: [PATCH 04/14] feat: ratings leaderboard archive explicit target --- .github/workflows/cd-asia-ratings-latest.yml | 2 +- .github/workflows/cd-asia-ratings-midnight.yml | 8 ++++---- .github/workflows/cd-eu-ratings-latest.yml | 8 ++++---- .github/workflows/cd-eu-ratings-midnight.yml | 8 ++++---- .github/workflows/cd-na-ratings-latest.yml | 2 +- .github/workflows/cd-na-ratings-midnight.yml | 2 +- scripts/buildRatingsLeaderboard.ts | 9 +++++---- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml index 85ba74d8f..93b327a33 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=latest diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-asia-ratings-midnight.yml index ebad9ad1a..2c4426498 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-asia-ratings-midnight.yml @@ -2,7 +2,7 @@ name: CD Asia Ratings Midnight on: schedule: - - cron: "0 17 * * *" + - cron: '0 17 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=midnight diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml index c988ee70e..dbcd36cb1 100644 --- a/.github/workflows/cd-eu-ratings-latest.yml +++ b/.github/workflows/cd-eu-ratings-latest.yml @@ -2,7 +2,7 @@ name: CD Europe Ratings Latest on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=latest diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-eu-ratings-midnight.yml index da778b527..3c0b88eed 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-eu-ratings-midnight.yml @@ -2,7 +2,7 @@ name: CD Europe Ratings Midnight on: schedule: - - cron: "0 23 * * *" + - cron: '0 23 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=midnight diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml index ff7ab3470..5b98bc8c7 100644 --- a/.github/workflows/cd-na-ratings-latest.yml +++ b/.github/workflows/cd-na-ratings-latest.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=latest diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml index 1426f7c31..23249a2d4 100644 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ b/.github/workflows/cd-na-ratings-midnight.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=midnight diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index c137f3e5d..a84929c02 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -23,9 +23,12 @@ export type BlitzkriegRatingsLeaderboardEntry = { id: number; score: number }; export type BlitzkriegRatingsLeaderboard = BlitzkriegRatingsLeaderboardEntry[]; const publish = argv.includes('--publish'); -const latest = argv.includes('--latest'); +const target = argv + .find((arg) => arg.startsWith('--target=')) + ?.split('=')[1] as 'midnight' | 'latest' | undefined; const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1]; +if (!target) throw new Error('Target parameter not specified'); if (!server) throw new Error('Region parameter not specified'); const NEIGHBORS = 2 ** 8; @@ -117,9 +120,7 @@ if (publish) { const normalizedServer = server === 'na' ? 'com' : server; const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`; - const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${ - latest ? 'latest' : 'midnight' - }.json`; + const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${target}.json`; const infoJSON = JSON.stringify(info); console.log(`Publishing to season ${info.current_season}...`); From c87a75f3fd7ef332617c9d01a8dad651d99af892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:01:12 -0600 Subject: [PATCH 05/14] feat: combined ratings archive workflows --- .github/workflows/cd-eu-ratings-latest.yml | 34 ------------------- .github/workflows/cd-na-ratings-latest.yml | 34 ------------------- .github/workflows/cd-na-ratings-midnight.yml | 34 ------------------- ...tings-midnight.yml => cd-ratings-asia.yml} | 8 +++-- ...ratings-midnight.yml => cd-ratings-eu.yml} | 8 +++-- ...a-ratings-latest.yml => cd-ratings-na.yml} | 8 +++-- 6 files changed, 18 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/cd-eu-ratings-latest.yml delete mode 100644 .github/workflows/cd-na-ratings-latest.yml delete mode 100644 .github/workflows/cd-na-ratings-midnight.yml rename .github/workflows/{cd-asia-ratings-midnight.yml => cd-ratings-asia.yml} (77%) rename .github/workflows/{cd-eu-ratings-midnight.yml => cd-ratings-eu.yml} (77%) rename .github/workflows/{cd-asia-ratings-latest.yml => cd-ratings-na.yml} (76%) diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml deleted file mode 100644 index dbcd36cb1..000000000 --- a/.github/workflows/cd-eu-ratings-latest.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD Europe Ratings Latest - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=latest diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml deleted file mode 100644 index 5b98bc8c7..000000000 --- a/.github/workflows/cd-na-ratings-latest.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD North America Ratings Latest - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=latest diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml deleted file mode 100644 index 23249a2d4..000000000 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD North America Ratings Midnight - -on: - schedule: - - cron: '0 5 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=midnight diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-ratings-asia.yml similarity index 77% rename from .github/workflows/cd-asia-ratings-midnight.yml rename to .github/workflows/cd-ratings-asia.yml index 2c4426498..6135fc719 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-ratings-asia.yml @@ -1,7 +1,11 @@ -name: CD Asia Ratings Midnight +name: CD Asia Ratings + +# latest: '0 0 * * *' +# asia midnight: '0 17 * * *' on: schedule: + - cron: '0 0 * * *' - cron: '0 17 * * *' jobs: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=midnight + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-ratings-eu.yml similarity index 77% rename from .github/workflows/cd-eu-ratings-midnight.yml rename to .github/workflows/cd-ratings-eu.yml index 3c0b88eed..b0f0d0a78 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-ratings-eu.yml @@ -1,7 +1,11 @@ -name: CD Europe Ratings Midnight +name: CD Europe Ratings + +# latest: '0 0 * * *' +# eu midnight: '0 23 * * *' on: schedule: + - cron: '0 0 * * *' - cron: '0 23 * * *' jobs: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=midnight + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-ratings-na.yml similarity index 76% rename from .github/workflows/cd-asia-ratings-latest.yml rename to .github/workflows/cd-ratings-na.yml index 93b327a33..8c91f1600 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-ratings-na.yml @@ -1,8 +1,12 @@ -name: CD Asia Ratings Latest +name: CD North America Ratings + +# latest: '0 0 * * *' +# na midnight: '0 5 * * *' on: schedule: - cron: '0 0 * * *' + - cron: '0 5 * * *' jobs: host: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} From a3e20501af8f1913f564137f2224bb83cfc53b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:08:01 -0600 Subject: [PATCH 06/14] feat: new credits transfer --- docs/guide/creators.md | 6 ++++++ src/commands/about.ts | 2 ++ src/commands/credits.ts | 15 --------------- src/events/interactionCreate/index.ts | 2 -- 4 files changed, 8 insertions(+), 17 deletions(-) create mode 100644 docs/guide/creators.md delete mode 100644 src/commands/credits.ts diff --git a/docs/guide/creators.md b/docs/guide/creators.md new file mode 100644 index 000000000..663fb39ab --- /dev/null +++ b/docs/guide/creators.md @@ -0,0 +1,6 @@ +# Creators + +- TrèsAbhi `@tresabhi` + - Creator & main programmer; _I do it all!_ +- Prince_NA `@prince_na` + - Advisor & tester diff --git a/src/commands/about.ts b/src/commands/about.ts index 63fbc6aa0..94b60fbf0 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -11,6 +11,7 @@ const DOCS = { introduction: 'guide/introduction', invite: 'guide/invite', timezones: 'guide/timezones', + creators: 'guide/creators', }; const DOC_DESCRIPTIONS: Record = { permissions: 'The permissions needed for the bot to function', @@ -18,6 +19,7 @@ const DOC_DESCRIPTIONS: Record = { introduction: 'About the bot', invite: 'How to invite the bot', timezones: 'How Blitzkrieg infers and uses your timezone', + creators: 'Who created the bot', }; function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) { diff --git a/src/commands/credits.ts b/src/commands/credits.ts deleted file mode 100644 index 9cbe952d1..000000000 --- a/src/commands/credits.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js'; -import { CommandRegistry } from '../events/interactionCreate'; - -export const creditsCommand: CommandRegistry = { - inProduction: true, - inPublic: true, - - command: new SlashCommandBuilder() - .setName('credits') - .setDescription('Me and the people who made this bot'), - - async handler() { - return new AttachmentBuilder('https://i.imgur.com/ZF5ch33.png'); - }, -}; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 6dedea8b9..0b7aeadcb 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -16,7 +16,6 @@ import { import discord from '../../../discord.json' assert { type: 'json' }; import { aboutCommand } from '../../commands/about'; import { breakdownCommand } from '../../commands/breakdown'; -import { creditsCommand } from '../../commands/credits'; import { debugCommand } from '../../commands/debug'; import { eligibleCommand } from '../../commands/eligible'; import { evolutionCommand } from '../../commands/evolution'; @@ -102,7 +101,6 @@ export const COMMANDS_RAW: CommandRegistry[] = [ evolutionCommand, statsCommand, ratingsCommand, - creditsCommand, ]; export const commands = Promise.all(COMMANDS_RAW).then((rawCommands) => From debaaccf4cea61142ef759d60ef7779698ab2e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:40:11 -0600 Subject: [PATCH 07/14] feat: presence --- .vscode/settings.json | 1 + src/core/discord/client.ts | 3 ++- src/events/ready.ts | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 45f0cf251..1c0d191e7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "fuzzysort", "immer", "kranvagn", + "krieg", "Leaderboard", "leaderboards", "MURICA", diff --git a/src/core/discord/client.ts b/src/core/discord/client.ts index d79c653d5..3b9e6bbd8 100644 --- a/src/core/discord/client.ts +++ b/src/core/discord/client.ts @@ -1,10 +1,11 @@ import { Client, GatewayIntentBits } from 'discord.js'; 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('ready', ready) .on('guildMemberAdd', guildMemberAdd) .on('interactionCreate', interactionCreate); diff --git a/src/events/ready.ts b/src/events/ready.ts index 3c24d0ab2..d589d2941 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,5 +1,23 @@ -import { Client } from 'discord.js'; +import { ActivityType, Client } from 'discord.js'; export default function ready(client: Client) { - console.log(`🟢 Launched bot ${client.shard?.ids[0]}`); + console.log(`🟢 Launched bot ${client.shard?.ids[0] ?? 'default'}`); + + const activities: (() => string)[] = [ + () => `Living in ${client.guilds.cache.size.toLocaleString()} servers`, + () => + `Serving ${client.guilds.cache + .reduce((accumulator, guild) => accumulator + guild.memberCount, 0) + .toLocaleString()} users`, + () => `Observing ${client.channels.cache.size.toLocaleString()} channels`, + ]; + + client.user.setPresence({ + activities: [ + { + type: ActivityType.Custom, + name: activities[Math.floor(Math.random() * activities.length)](), + }, + ], + }); } From f5425d0e546504ade1907e4b1258c92d7941bacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:45:00 -0600 Subject: [PATCH 08/14] fix: more accurate user count --- src/events/ready.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index d589d2941..d63ceeb31 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -5,10 +5,7 @@ export default function ready(client: Client) { const activities: (() => string)[] = [ () => `Living in ${client.guilds.cache.size.toLocaleString()} servers`, - () => - `Serving ${client.guilds.cache - .reduce((accumulator, guild) => accumulator + guild.memberCount, 0) - .toLocaleString()} users`, + () => `Serving ${client.users.cache.size.toLocaleString()} users`, () => `Observing ${client.channels.cache.size.toLocaleString()} channels`, ]; From f728751fa90387b522100755f176bd040a0b71e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:46:20 -0600 Subject: [PATCH 09/14] feat: better debug --- src/commands/debug.ts | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 7b1254add..70ac62ad9 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -1,11 +1,6 @@ import { SlashCommandBuilder } from 'discord.js'; import packageJSON from '../../package.json' assert { type: 'json' }; -import getClientId from '../core/blitzkrieg/getClientId'; -import { tankAverages } from '../core/blitzstars/tankAverages'; -import { tankopedia } from '../core/blitzstars/tankopedia'; import { client } from '../core/discord/client'; -import embedInfo from '../core/discord/embedInfo'; -import markdownTable from '../core/discord/markdownTable'; import { CommandRegistry } from '../events/interactionCreate'; const executionStart = new Date().getTime(); @@ -21,24 +16,21 @@ export const debugCommand: CommandRegistry = { async handler(interaction) { const currentTime = new Date().getTime(); const uptime = currentTime - executionStart; + const list = [ + ['Version', packageJSON.version], + ['Shard', client.shard?.ids[0] ?? 'default'], + [ + 'Uptime', + `${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor( + (uptime / 1000 / 60) % 60, + )}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor( + uptime % 1000, + )}ms`, + ], + ] + .map(([key, value]) => `- ${key}: ${value}`) + .join('\n'); - return embedInfo( - `${client.user?.username} debug information`, - markdownTable([ - ['Version', packageJSON.version], - ['Client ID', getClientId()], - ['Tag', interaction.client.user.tag], - [ - 'Uptime', - `${Math.floor(uptime / 1000 / 60 / 60 / 24)}d ${Math.floor( - (uptime / 1000 / 60 / 60) % 24, - )}h ${Math.floor((uptime / 1000 / 60) % 60)}m ${Math.floor( - (uptime / 1000) % 60, - )}s ${Math.floor(uptime % 1000)}ms`, - ], - ['Tankopedia cached', `${(await tankopedia) !== undefined}`], - ['Tank averages cached', `${(await tankAverages) !== undefined}`], - ]), - ); + return `# Debug\n\n${list}`; }, }; From 3bbbbfa402b232152b07815a860f22d9d33be303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:57:58 -0600 Subject: [PATCH 10/14] feat: changelogs --- docs/changelogs/1.15.3.md | 22 ++++++++++++++++++++++ package.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/changelogs/1.15.3.md diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md new file mode 100644 index 000000000..0b01c692b --- /dev/null +++ b/docs/changelogs/1.15.3.md @@ -0,0 +1,22 @@ +# Blitzkrieg 1.15.3 + +The bot now gets more expressive! + +## Features + +- The bot can now have presence messages; examples: + - "Living in servers" + - "Server users" + - "Observing channels" + - More will be added in the future! Give me some ideas + +## Changes + +- Moved `/credits` to `/about creators` +- `/debug` command now ditches embeds and has better information to serve + +## Technical Changes + +- Removed manual trigger for Asian latest ratings leaderboard archiver +- Leaderboard archiver now accepts an explicit target like `midnight` or `latest` +- Combined midnight and latest leaderboard archival workflow into one file diff --git a/package.json b/package.json index 7342591a2..4b549bce7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.2", + "version": "1.15.3", "description": "🎉 Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", From 750e145f0389059d012a4bf581602c8f65828933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:03:29 -0600 Subject: [PATCH 11/14] feat: version lint --- .github/workflows/cd-version.yml | 32 ++++++++++++++++++++++++++++++++ docs/changelogs/1.15.3.md | 4 ++++ package.json | 1 + scripts/checkVersionMissMatch.ts | 12 ++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .github/workflows/cd-version.yml create mode 100644 scripts/checkVersionMissMatch.ts diff --git a/.github/workflows/cd-version.yml b/.github/workflows/cd-version.yml new file mode 100644 index 000000000..db7935531 --- /dev/null +++ b/.github/workflows/cd-version.yml @@ -0,0 +1,32 @@ +name: CD Version + +on: [push, pull_request] + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: yarn lint:version diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index 0b01c692b..c85cc7bf8 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -15,6 +15,10 @@ The bot now gets more expressive! - Moved `/credits` to `/about creators` - `/debug` command now ditches embeds and has better information to serve +## Technical Features + +- Added a workflow and lint for package and changelog version miss match + ## Technical Changes - Removed manual trigger for Asian latest ratings leaderboard archiver diff --git a/package.json b/package.json index 4b549bce7..d9c1af04f 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "npx tsc", "lint:website": "next lint", "format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"", + "lint:version": "vite-node --script scripts/checkVersionMissMatch", "knip": "knip", "update": "yarn upgrade --latest" }, diff --git a/scripts/checkVersionMissMatch.ts b/scripts/checkVersionMissMatch.ts new file mode 100644 index 000000000..a13c9351e --- /dev/null +++ b/scripts/checkVersionMissMatch.ts @@ -0,0 +1,12 @@ +import { readdir } from 'fs/promises'; +import packageJSON from '../package.json'; + +const { version } = packageJSON; +const changelogs = await readdir('docs/changelogs'); +const hasVersion = changelogs.includes(`${version}.md`); + +if (hasVersion) { + console.log(`Version ${version} found in changelogs`); +} else { + throw new Error(`Version ${version} not found in changelogs`); +} From 222fa89422f048be8e2c90b77544d84c74932664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:04:04 -0600 Subject: [PATCH 12/14] fix: remove pull request --- .github/workflows/cd-version.yml | 2 +- .github/workflows/ci-build-bot.yml | 2 +- .github/workflows/ci-build-docs.yml | 2 +- .github/workflows/ci-build-website.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd-version.yml b/.github/workflows/cd-version.yml index db7935531..33813f6e2 100644 --- a/.github/workflows/cd-version.yml +++ b/.github/workflows/cd-version.yml @@ -1,6 +1,6 @@ name: CD Version -on: [push, pull_request] +on: [push] jobs: host: diff --git a/.github/workflows/ci-build-bot.yml b/.github/workflows/ci-build-bot.yml index 1a3f05e23..2a4c43690 100644 --- a/.github/workflows/ci-build-bot.yml +++ b/.github/workflows/ci-build-bot.yml @@ -1,6 +1,6 @@ name: CI Build Bot -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-docs.yml b/.github/workflows/ci-build-docs.yml index 79c7c3095..8f083841a 100644 --- a/.github/workflows/ci-build-docs.yml +++ b/.github/workflows/ci-build-docs.yml @@ -1,6 +1,6 @@ name: CI Build Docs -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-website.yml b/.github/workflows/ci-build-website.yml index 4f48e8b62..5a2b81c9e 100644 --- a/.github/workflows/ci-build-website.yml +++ b/.github/workflows/ci-build-website.yml @@ -1,6 +1,6 @@ name: CI Build Website -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 25e1f4caa449284c4565ef91266637898a5e58fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:09:24 -0600 Subject: [PATCH 13/14] fix: workflow triggers --- .github/workflows/cd-docs.yml | 2 +- .github/workflows/ci-build-bot.yml | 2 +- .github/workflows/ci-build-docs.yml | 2 +- .github/workflows/ci-build-website.yml | 2 +- .github/workflows/{cd-version.yml => ci-version.yml} | 4 ++-- docs/changelogs/1.15.3.md | 4 ++++ 6 files changed, 10 insertions(+), 6 deletions(-) rename .github/workflows/{cd-version.yml => ci-version.yml} (95%) diff --git a/.github/workflows/cd-docs.yml b/.github/workflows/cd-docs.yml index 61855855e..74d93ec97 100644 --- a/.github/workflows/cd-docs.yml +++ b/.github/workflows/cd-docs.yml @@ -2,7 +2,7 @@ name: CD Docs on: push: - branches: [main] + branches: main jobs: build: diff --git a/.github/workflows/ci-build-bot.yml b/.github/workflows/ci-build-bot.yml index 2a4c43690..2f29938cb 100644 --- a/.github/workflows/ci-build-bot.yml +++ b/.github/workflows/ci-build-bot.yml @@ -1,6 +1,6 @@ name: CI Build Bot -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-docs.yml b/.github/workflows/ci-build-docs.yml index 8f083841a..c9dfbaca0 100644 --- a/.github/workflows/ci-build-docs.yml +++ b/.github/workflows/ci-build-docs.yml @@ -1,6 +1,6 @@ name: CI Build Docs -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-website.yml b/.github/workflows/ci-build-website.yml index 5a2b81c9e..66c3eb778 100644 --- a/.github/workflows/ci-build-website.yml +++ b/.github/workflows/ci-build-website.yml @@ -1,6 +1,6 @@ name: CI Build Website -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/cd-version.yml b/.github/workflows/ci-version.yml similarity index 95% rename from .github/workflows/cd-version.yml rename to .github/workflows/ci-version.yml index 33813f6e2..3e567d42d 100644 --- a/.github/workflows/cd-version.yml +++ b/.github/workflows/ci-version.yml @@ -1,6 +1,6 @@ -name: CD Version +name: CI Version -on: [push] +on: push jobs: host: diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index c85cc7bf8..a10364bdf 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -24,3 +24,7 @@ The bot now gets more expressive! - Removed manual trigger for Asian latest ratings leaderboard archiver - Leaderboard archiver now accepts an explicit target like `midnight` or `latest` - Combined midnight and latest leaderboard archival workflow into one file + +## Technical Fixed + +- Reviewed all workflow triggers and updated them From 10f64902aaca32868265aab7e304d1c3353a0038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:10:53 -0600 Subject: [PATCH 14/14] fix: xml in md --- docs/changelogs/1.15.3.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index a10364bdf..8772fc54a 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -5,9 +5,9 @@ The bot now gets more expressive! ## Features - The bot can now have presence messages; examples: - - "Living in servers" - - "Server users" - - "Observing channels" + - "Living in {number} servers" + - "Server {number} users" + - "Observing {number} channels" - More will be added in the future! Give me some ideas ## Changes