mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: better cyclic.sh script compatibility
This commit is contained in:
1 parent
4e49d22c4c
commit
3330dce264
13 files changed
+72
-164
No files matched your search
@@ -11,7 +11,7 @@ import { client } from '../index.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -72,7 +72,6 @@ export default {
|
||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${wargamingApplicationId}&account_id=${id}&extra=clan`,
|
||||
);
|
||||
|
||||
console.time('ownedtanks');
|
||||
const image = await render(
|
||||
<Wrapper>
|
||||
{/* TODO: integrate some of these into title bar */}
|
||||
@@ -109,7 +108,6 @@ export default {
|
||||
);
|
||||
|
||||
await interaction.editReply({ files: [image] });
|
||||
console.timeEnd('ownedtanks');
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
||||
@@ -1,28 +1,9 @@
|
||||
import { argv } from 'process';
|
||||
import errorWithCause from './errorWithCause.js';
|
||||
export const discordToken = process.env.DISCORD_TOKEN!;
|
||||
export const wargamingApplicationId = process.env.WARGAMING_APPLICATION_ID!;
|
||||
|
||||
type ArgumentName = 'discord-token' | 'wargaming-application-id';
|
||||
|
||||
const args: Record<ArgumentName, string> = {
|
||||
'discord-token': '',
|
||||
'wargaming-application-id': '',
|
||||
};
|
||||
|
||||
argv.forEach((arg) => {
|
||||
if (arg.includes('=')) {
|
||||
const [name, value] = arg.split('=');
|
||||
args[name as ArgumentName] = value;
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(args).forEach((arg) => {
|
||||
if (args[arg as ArgumentName] === '') {
|
||||
throw errorWithCause(
|
||||
`Missing argument: ${arg}`,
|
||||
'Missing required auth key.',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export const discordToken = args['discord-token'];
|
||||
export const wargamingApplicationId = args['wargaming-application-id'];
|
||||
if (!discordToken) {
|
||||
throw new Error('No Discord token provided');
|
||||
}
|
||||
if (!wargamingApplicationId) {
|
||||
throw new Error('No Wargaming application id provided}');
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
const isDevBoolean = process.argv.includes('--dev');
|
||||
const isDevBoolean = process.env.NODE_ENV === 'development';
|
||||
|
||||
export default function isDev() {
|
||||
return isDevBoolean;
|
||||
}
|
||||
|
||||
console.log(process.env.NODE_ENV);
|
||||
+15
-9
@@ -1,28 +1,34 @@
|
||||
import { Resvg } from '@resvg/resvg-js';
|
||||
import { readFile } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { ReactNode } from 'react';
|
||||
import satori from 'satori';
|
||||
import robotoBlackFile from '../../assets/fonts/Roboto-Black.ttf';
|
||||
import robotoBoldFile from '../../assets/fonts/Roboto-Bold.ttf';
|
||||
import robotoFile from '../../assets/fonts/Roboto.ttf';
|
||||
|
||||
const FONT_NAME = 'Roboto';
|
||||
const FONT_FILES = ['Roboto', 'Roboto-Bold', 'Roboto-Black'];
|
||||
const FONT_FILES = [robotoFile, robotoBoldFile, robotoBlackFile];
|
||||
|
||||
let robotoFlex: Buffer;
|
||||
let robotoFlexBold: Buffer;
|
||||
let robotoFlexBlack: Buffer;
|
||||
let roboto: Buffer;
|
||||
let robotoBold: Buffer;
|
||||
let robotoBlack: Buffer;
|
||||
|
||||
console.log('Importing fonts...');
|
||||
Promise.all(
|
||||
FONT_FILES.map(
|
||||
(file) =>
|
||||
new Promise<Buffer>((resolve, reject) => {
|
||||
readFile(`src/assets/fonts/${file}.ttf`, (error, data) => {
|
||||
const path = join(__dirname, file);
|
||||
|
||||
readFile(path, (error, data) => {
|
||||
if (error) reject(error);
|
||||
resolve(data);
|
||||
});
|
||||
}),
|
||||
),
|
||||
).then((data) => {
|
||||
[robotoFlex, robotoFlexBold, robotoFlexBlack] = data;
|
||||
[roboto, robotoBold, robotoBlack] = data;
|
||||
console.log('Fonts imported');
|
||||
});
|
||||
|
||||
@@ -30,9 +36,9 @@ export default async function render(element: ReactNode) {
|
||||
const svg = await satori(element, {
|
||||
width: 640,
|
||||
fonts: [
|
||||
{ data: robotoFlex, name: FONT_NAME, weight: 400 },
|
||||
{ data: robotoFlexBold, name: FONT_NAME, weight: 700 },
|
||||
{ data: robotoFlexBlack, name: FONT_NAME, weight: 900 },
|
||||
{ data: roboto, name: FONT_NAME, weight: 400 },
|
||||
{ data: robotoBold, name: FONT_NAME, weight: 700 },
|
||||
{ data: robotoBlack, name: FONT_NAME, weight: 900 },
|
||||
],
|
||||
});
|
||||
const png = new Resvg(svg).render().asPng();
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '*.ttf' {
|
||||
const path: string;
|
||||
export default path;
|
||||
}
|
||||
Reference in new issue
Block a user