mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: simpler logging
This commit is contained in:
1 parent
43f634e198
commit
9495ae2336
7 files changed
+7
-22
No files matched your search
@@ -2,5 +2,7 @@ import { registerProcesses } from './core/blitzkrieg/processes';
|
|||||||
import { secrets } from './core/blitzkrieg/secrets';
|
import { secrets } from './core/blitzkrieg/secrets';
|
||||||
import { client } from './core/discord/client';
|
import { client } from './core/discord/client';
|
||||||
|
|
||||||
|
console.log(`🟡 Launching bot ${client.shard?.ids[0]}`);
|
||||||
|
|
||||||
registerProcesses();
|
registerProcesses();
|
||||||
client.login(secrets.DISCORD_TOKEN);
|
client.login(secrets.DISCORD_TOKEN);
|
||||||
@@ -12,7 +12,6 @@ let roboto: Buffer;
|
|||||||
let robotoBold: Buffer;
|
let robotoBold: Buffer;
|
||||||
let robotoBlack: Buffer;
|
let robotoBlack: Buffer;
|
||||||
|
|
||||||
console.log('Importing fonts...');
|
|
||||||
Promise.all(
|
Promise.all(
|
||||||
FONT_FILES.map(
|
FONT_FILES.map(
|
||||||
(file) =>
|
(file) =>
|
||||||
@@ -27,7 +26,6 @@ Promise.all(
|
|||||||
),
|
),
|
||||||
).then((data) => {
|
).then((data) => {
|
||||||
[roboto, robotoBold, robotoBlack] = data;
|
[roboto, robotoBold, robotoBlack] = data;
|
||||||
console.log('Fonts imported');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default async function jsxToSvg(jsx: JSX.Element) {
|
export default async function jsxToSvg(jsx: JSX.Element) {
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ tankopedia;
|
|||||||
|
|
||||||
export type TankAverages = Record<number, IndividualTankAverage>;
|
export type TankAverages = Record<number, IndividualTankAverage>;
|
||||||
|
|
||||||
console.log('Caching tank averages...');
|
|
||||||
export const tankAverages = fetch(
|
export const tankAverages = fetch(
|
||||||
context === 'bot'
|
context === 'bot'
|
||||||
? 'https://www.blitzstars.com/api/tankaverages.json'
|
? 'https://www.blitzstars.com/api/tankaverages.json'
|
||||||
@@ -100,8 +99,6 @@ export const tankAverages = fetch(
|
|||||||
individualTankAverage;
|
individualTankAverage;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Tank averages cached');
|
|
||||||
|
|
||||||
return partialTankAverages;
|
return partialTankAverages;
|
||||||
} else {
|
} else {
|
||||||
return json as TankAverages;
|
return json as TankAverages;
|
||||||
|
|||||||
@@ -27,12 +27,11 @@ export const tankopedia = fetch(
|
|||||||
: '/api/tankopedia',
|
: '/api/tankopedia',
|
||||||
)
|
)
|
||||||
.then(async (response) => response.json())
|
.then(async (response) => response.json())
|
||||||
.then((wrapperTankopedia) => {
|
.then((wrapperTankopedia) =>
|
||||||
console.log('Tankopedia cached');
|
context === 'bot'
|
||||||
return context === 'bot'
|
|
||||||
? (wrapperTankopedia as { data: Tankopedia }).data
|
? (wrapperTankopedia as { data: Tankopedia }).data
|
||||||
: (wrapperTankopedia as Tankopedia);
|
: (wrapperTankopedia as Tankopedia),
|
||||||
});
|
);
|
||||||
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
|
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||||
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
||||||
});
|
});
|
||||||
@@ -69,11 +68,9 @@ export interface TankopediaInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this is blocking because info is needed for command creation
|
// this is blocking because info is needed for command creation
|
||||||
console.log('Caching tankopedia info...');
|
|
||||||
export const tankopediaInfo = fetchBlitz<TankopediaInfo>(
|
export const tankopediaInfo = fetchBlitz<TankopediaInfo>(
|
||||||
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
||||||
);
|
);
|
||||||
console.log('Cached tankopedia info');
|
|
||||||
|
|
||||||
export const TANK_ICONS: Record<string, string> = {
|
export const TANK_ICONS: Record<string, string> = {
|
||||||
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ export interface PSA {
|
|||||||
|
|
||||||
export const psa: PSA = { data: null };
|
export const psa: PSA = { data: null };
|
||||||
|
|
||||||
console.log('Caching PSA...');
|
|
||||||
fetch(
|
fetch(
|
||||||
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
|
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
|
||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
psa.data = data as PSAData;
|
psa.data = data as PSAData;
|
||||||
console.log('PSA cached');
|
|
||||||
});
|
});
|
||||||
@@ -136,12 +136,10 @@ commands.then((awaitedCommands) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`Refreshing ${publicCommands.length} public command(s).`);
|
|
||||||
rest.put(Routes.applicationCommands(getClientId()), {
|
rest.put(Routes.applicationCommands(getClientId()), {
|
||||||
body: publicCommands,
|
body: publicCommands,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Refreshing ${guildCommands.length} guild command(s).`);
|
|
||||||
(isDev()
|
(isDev()
|
||||||
? [discord.test_guild_id]
|
? [discord.test_guild_id]
|
||||||
: [discord.tres_guild_id, discord.sklld_guild_id]
|
: [discord.tres_guild_id, discord.sklld_guild_id]
|
||||||
|
|||||||
+1
-6
@@ -1,10 +1,5 @@
|
|||||||
import { Client } from 'discord.js';
|
import { Client } from 'discord.js';
|
||||||
import isDev from '../core/blitzkrieg/isDev';
|
|
||||||
|
|
||||||
export default function ready(client: Client<true>) {
|
export default function ready(client: Client<true>) {
|
||||||
console.log(
|
console.log(`🟢 Bot ${client.shard?.ids[0]} launched`);
|
||||||
`Logged in as ${client.user.tag} in ${
|
|
||||||
isDev() ? 'development' : 'production'
|
|
||||||
} mode across ${client.guilds.cache.size} servers`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user