mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
fix: port to core 3
This commit is contained in:
1 parent
5e989a16bc
commit
de6a4d5675
29 files changed
+27
-20
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import sharp from 'sharp';
|
||||
|
||||
const cache: Record<string, Buffer> = {};
|
||||
|
||||
export async function iconPng(url: string) {
|
||||
if (!url.endsWith('.webp')) return url;
|
||||
|
||||
if (!cache[url]) {
|
||||
const imageResponse = await fetch(url);
|
||||
const imageBufferWEBP = await imageResponse.arrayBuffer();
|
||||
const imageBufferPNG = await sharp(imageBufferWEBP).png().toBuffer();
|
||||
cache[url] = imageBufferPNG;
|
||||
}
|
||||
|
||||
return `data:image/png;base64,${cache[url].toString('base64')}`;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RenderConfiguration } from '../../../../website/src/core/blitzkit/renderConfiguration';
|
||||
import { jsxToSvg } from './jsxToSvg';
|
||||
import { RenderConfiguration } from './renderConfiguration';
|
||||
import { svgToPngThreaded } from './svgToPngThreaded';
|
||||
|
||||
export async function jsxToPngThreaded(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readFile } from 'fs/promises';
|
||||
import satori from 'satori';
|
||||
import { RenderConfiguration } from '../../../../../website/src/core/blitzkit/renderConfiguration';
|
||||
import { RenderConfiguration } from '../renderConfiguration';
|
||||
import robotoBlack from './Roboto-Black.ttf';
|
||||
import robotoBold from './Roboto-Bold.ttf';
|
||||
import roboto from './Roboto.ttf';
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface RenderConfiguration {
|
||||
width: number;
|
||||
}
|
||||
|
||||
export class RenderConfiguration implements RenderConfiguration {
|
||||
width = 480;
|
||||
|
||||
constructor(configuration?: Partial<RenderConfiguration>) {
|
||||
Object.assign(this, configuration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { tankIcon } from '@blitzkit/core';
|
||||
import { iconPng } from './iconPng';
|
||||
|
||||
export function tankIconPng(id: number) {
|
||||
return iconPng(tankIcon(id));
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
InteractionReplyOptions,
|
||||
MessageEditOptions,
|
||||
} from 'discord.js';
|
||||
import { RenderConfiguration } from '../../../../website/src/core/blitzkit/renderConfiguration';
|
||||
import { InteractionReturnable } from '../../events/interactionCreate';
|
||||
import { Writeable } from '../../types/writable';
|
||||
import { jsxToPngThreaded } from '../blitzkit/jsxToPngThreaded';
|
||||
import { RenderConfiguration } from '../blitzkit/renderConfiguration';
|
||||
|
||||
export async function normalizeInteractionReturnable(
|
||||
returnable: InteractionReturnable,
|
||||
|
||||
Reference in new issue
Block a user