mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +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
@@ -11,12 +11,12 @@ import {
|
||||
import { SlashCommandSubcommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { emblemURL } from '../../../website/src/core/blitzkit/emblemURL';
|
||||
import { iconPng } from '../../../website/src/core/blitzkit/iconPng';
|
||||
import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow';
|
||||
import { CommandWrapper } from '../components/CommandWrapper';
|
||||
import { DeltaCaret } from '../components/DeltaCaret';
|
||||
import { TitleBar } from '../components/TitleBar';
|
||||
import { normalizeLeagueIcon } from '../core/blitz/normalizeLeagueIcon';
|
||||
import { iconPng } from '../core/blitzkit/iconPng';
|
||||
import { addUsernameChoices } from '../core/discord/addUsernameChoices';
|
||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||
import { resolvePlayerFromCommand } from '../core/discord/resolvePlayerFromCommand';
|
||||
|
||||
@@ -9,11 +9,11 @@ import {
|
||||
} from '@blitzkit/core';
|
||||
import { clamp } from 'lodash';
|
||||
import { emblemURL } from '../../../website/src/core/blitzkit/emblemURL';
|
||||
import { iconPng } from '../../../website/src/core/blitzkit/iconPng';
|
||||
import { mapDefinitions } from '../../../website/src/core/blitzkit/mapDefinitions';
|
||||
import { RenderConfiguration } from '../../../website/src/core/blitzkit/renderConfiguration';
|
||||
import { CommandWrapper } from '../components/CommandWrapper';
|
||||
import { TitleBar } from '../components/TitleBar';
|
||||
import { iconPng } from '../core/blitzkit/iconPng';
|
||||
import { RenderConfiguration } from '../core/blitzkit/renderConfiguration';
|
||||
import { buttonLink } from '../core/discord/buttonLink';
|
||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||
import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
@@ -11,12 +11,12 @@ import {
|
||||
import { escapeMarkdown, Locale } from 'discord.js';
|
||||
import { buildTechTreeLine } from '../../../website/src/core/blitzkit/buildTechTreeLine';
|
||||
import { emblemURL } from '../../../website/src/core/blitzkit/emblemURL';
|
||||
import { iconPng } from '../../../website/src/core/blitzkit/iconPng';
|
||||
import { resolveAncestry } from '../../../website/src/core/blitzkit/resolveAncestry';
|
||||
import { tankIconPng } from '../../../website/src/core/blitzkit/tankIconPng';
|
||||
import { CommandWrapper } from '../components/CommandWrapper';
|
||||
import { TitleBar } from '../components/TitleBar';
|
||||
import { resolveTankId } from '../core/blitz/resolveTankId';
|
||||
import { iconPng } from '../core/blitzkit/iconPng';
|
||||
import { addUsernameChoices } from '../core/discord/addUsernameChoices';
|
||||
import { autocompleteTanks } from '../core/discord/autocompleteTanks';
|
||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
SlashCommandOptionsOnlyBuilder,
|
||||
SlashCommandSubcommandsOnlyBuilder,
|
||||
} from 'discord.js';
|
||||
import { RenderConfiguration } from '../../../../website/src/core/blitzkit/renderConfiguration';
|
||||
import { aboutCommand } from '../../commands/about';
|
||||
import { breakdownCommand } from '../../commands/breakdown';
|
||||
import { debugCommand } from '../../commands/debug';
|
||||
@@ -34,6 +33,7 @@ import { searchClansCommand } from '../../commands/searchClans';
|
||||
import { searchPlayersCommand } from '../../commands/searchPlayers';
|
||||
import { statsCommand } from '../../commands/stats';
|
||||
import { todayCommand } from '../../commands/today';
|
||||
import { RenderConfiguration } from '../../core/blitzkit/renderConfiguration';
|
||||
import { handleAutocomplete } from './handlers/autocomplete';
|
||||
import { handleButton } from './handlers/button';
|
||||
import { handleChatInputCommand } from './handlers/chatInputCommand';
|
||||
|
||||
Reference in new issue
Block a user