fix: skip encoding tanks without images

This commit is contained in:
TresAbhi committed 2023-06-03 18:25:33 +00:00
1 parent db881f44d4
commit 1d0b428921
14 files changed
+28 -49

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ const executionStart = new Date().getTime();
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -11,7 +11,7 @@ import { client } from '../index.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -15,7 +15,7 @@ const DEFAULT_THRESHOLD = 7;
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -36,7 +36,7 @@ const COMP_TANKS = [
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -17,7 +17,7 @@ type SortBy = 'name' | 'count';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -13,7 +13,7 @@ import { AccountInfo } from '../types/accountInfo.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -12,7 +12,7 @@ import { ClanList } from '../types/clanList.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -13,7 +13,7 @@ import { AccountList } from '../types/accountList.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -9,7 +9,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -40,7 +40,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -40,7 +40,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -32,7 +32,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+1 -1
View File
@@ -14,7 +14,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
export default { export default {
inProduction: true, inProduction: true,
inDevelopment: true, inDevelopment: false,
inPublic: true, inPublic: true,
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
+15 -36
View File
@@ -1,27 +1,7 @@
import { WargamingResponse } from '../../types/wargamingResponse.js'; import { WargamingResponse } from '../../types/wargamingResponse.js';
import URLToBase64 from '../ui/URLToBase64.js';
/* export interface TankopediaEntry {
"1": {
"name": "T-34",
"nation": "ussr",
"is_premium": false,
"tier": 5,
"cost": {
"price_credit": 400000,
"price_gold": 0
},
"images": {
"preview": "/api/bs-cache/tank-icons/https%3A%2F%2Fglossary-eu-static.gcdn.co%2Ficons%2Fwotb%2Fcurrent%2Fuploaded%2Fvehicles%2Fhd_thumbnail%2FT-34.png",
"normal": "http://glossary-eu-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd/T-34.png"
},
"tank_id": 1,
"type": "mediumTank",
"description": "The legend of the Soviet armored forces and the most widely-produced Soviet tank of World War II, with a total of 33,805 vehicles manufactured. Three variants of this model were produced at several Soviet factories from 1940 through 1944."
},
*/
export interface Tankopedia {
[id: number]: {
name: string; name: string;
nation: string; nation: string;
is_premium: boolean; is_premium: boolean;
@@ -31,7 +11,10 @@ export interface Tankopedia {
tank_id: number; tank_id: number;
type: string; type: string;
description: string; description: string;
}; }
export interface Tankopedia {
[id: number]: TankopediaEntry;
} }
console.log('Caching tankopedia...'); console.log('Caching tankopedia...');
@@ -56,16 +39,12 @@ export const TANK_IDS = Object.keys(tankopedia).map((id) => Number(id));
export const TANKS = TANK_IDS.map((id) => tankopedia[id]); export const TANKS = TANK_IDS.map((id) => tankopedia[id]);
export const TANK_NAMES = TANKS.map((tank) => tank.name); export const TANK_NAMES = TANKS.map((tank) => tank.name);
// console.log('Encoding tank images...'); console.log('Encoding tank images...');
// await Promise.all( await Promise.all(
// Object.entries(tankopedia).map(async ([, tank]) => { Object.entries(tankopedia).map(async ([, tank]) => {
// try { if (tank.images.normal) {
// tank.images.normal = await URLToBase64(tank.images.normal); tank.images.normal = await URLToBase64(tank.images.normal);
// } catch (error) { }
// console.warn( }),
// `Failed to encode tank image for ${tank.images.normal}: ${error}`, );
// ); console.log('Encoded tank images');
// }
// }),
// );
// console.log('Encoded tank images');