mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: types
This commit is contained in:
1 parent
42b169cf60
commit
742290b3c0
12 files changed
+38
-21
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { Locale, SlashCommandBuilder } from 'discord.js';
|
import { Locale } from 'discord.js';
|
||||||
import CommandWrapper from '../components/CommandWrapper';
|
import CommandWrapper from '../components/CommandWrapper';
|
||||||
import GenericStats from '../components/GenericStats';
|
import GenericStats from '../components/GenericStats';
|
||||||
import NoData from '../components/NoData';
|
import NoData from '../components/NoData';
|
||||||
@@ -39,7 +39,7 @@ export const inactiveCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.setMinValue(0);
|
.setMinValue(0);
|
||||||
}) as SlashCommandBuilder,
|
}),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const { translate } = translator(interaction.locale);
|
const { translate } = translator(interaction.locale);
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ import { readDVPLFile } from './readDVPLFile';
|
|||||||
export async function extractArmor(data: string, fileName: string) {
|
export async function extractArmor(data: string, fileName: string) {
|
||||||
const sc2Path = `${data}/3d/Tanks/CollisionMeshes/${fileName}.sc2.dvpl`;
|
const sc2Path = `${data}/3d/Tanks/CollisionMeshes/${fileName}.sc2.dvpl`;
|
||||||
const scgPath = `${data}/3d/Tanks/CollisionMeshes/${fileName}.scg.dvpl`;
|
const scgPath = `${data}/3d/Tanks/CollisionMeshes/${fileName}.scg.dvpl`;
|
||||||
const sc2 = new Sc2ReadStream((await readDVPLFile(sc2Path)).buffer).sc2();
|
const sc2 = new Sc2ReadStream(
|
||||||
const scg = new ScgReadStream((await readDVPLFile(scgPath)).buffer).scg();
|
(await readDVPLFile(sc2Path)).buffer as ArrayBuffer,
|
||||||
|
).sc2();
|
||||||
|
const scg = new ScgReadStream(
|
||||||
|
(await readDVPLFile(scgPath)).buffer as ArrayBuffer,
|
||||||
|
).scg();
|
||||||
const document = new Document();
|
const document = new Document();
|
||||||
const scene = document.createScene();
|
const scene = document.createScene();
|
||||||
const buffer = document.createBuffer();
|
const buffer = document.createBuffer();
|
||||||
|
|||||||
@@ -23,8 +23,12 @@ const omitMeshNames = {
|
|||||||
export async function extractModel(data: string, path: string) {
|
export async function extractModel(data: string, path: string) {
|
||||||
const sc2Path = `${data}/3d/${path}.sc2.dvpl`;
|
const sc2Path = `${data}/3d/${path}.sc2.dvpl`;
|
||||||
const scgPath = `${data}/3d/${path}.scg.dvpl`;
|
const scgPath = `${data}/3d/${path}.scg.dvpl`;
|
||||||
const sc2 = new Sc2ReadStream((await readDVPLFile(sc2Path)).buffer).sc2();
|
const sc2 = new Sc2ReadStream(
|
||||||
const scg = new ScgReadStream((await readDVPLFile(scgPath)).buffer).scg();
|
(await readDVPLFile(sc2Path)).buffer as ArrayBuffer,
|
||||||
|
).sc2();
|
||||||
|
const scg = new ScgReadStream(
|
||||||
|
(await readDVPLFile(scgPath)).buffer as ArrayBuffer,
|
||||||
|
).scg();
|
||||||
const document = new Document();
|
const document = new Document();
|
||||||
const scene = document.createScene();
|
const scene = document.createScene();
|
||||||
const buffer = document.createBuffer();
|
const buffer = document.createBuffer();
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ import { superDecompress } from './superDecompress';
|
|||||||
export async function fetchCdonLz4<Type>(url: string) {
|
export async function fetchCdonLz4<Type>(url: string) {
|
||||||
return await fetch(url, { cache: 'no-store' })
|
return await fetch(url, { cache: 'no-store' })
|
||||||
.then((response) => response.arrayBuffer())
|
.then((response) => response.arrayBuffer())
|
||||||
.then((buffer) => superDecompress<Type>(new Uint8Array(buffer)));
|
.then((buffer) => superDecompress<Type>(buffer));
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,7 @@ export default async function getArchivedRatingInfo(
|
|||||||
)
|
)
|
||||||
.then((response) => response.arrayBuffer())
|
.then((response) => response.arrayBuffer())
|
||||||
.then((buffer) =>
|
.then((buffer) =>
|
||||||
superDecompress<RatingInfo & { detail: undefined }>(
|
superDecompress<RatingInfo & { detail: undefined }>(buffer),
|
||||||
new Uint8Array(buffer),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
cache[region][season] = info;
|
cache[region][season] = info;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ export async function readTexture(path: string, mutation?: TextureMutation) {
|
|||||||
const decompressedDvpl = await readDVPLFile(resolvedTexturePath);
|
const decompressedDvpl = await readDVPLFile(resolvedTexturePath);
|
||||||
|
|
||||||
const raw = isDds
|
const raw = isDds
|
||||||
? await new DdsReadStream(decompressedDvpl.buffer).dds()
|
? await new DdsReadStream(decompressedDvpl.buffer as ArrayBuffer).dds()
|
||||||
: new PvrReadStream(decompressedDvpl.buffer).pvr();
|
: new PvrReadStream(decompressedDvpl.buffer as ArrayBuffer).pvr();
|
||||||
|
|
||||||
switch (mutation) {
|
switch (mutation) {
|
||||||
case TextureMutation.Normal: {
|
case TextureMutation.Normal: {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { decompress } from 'lz4js';
|
|||||||
import { CdonReadStream } from '../streams/cdon';
|
import { CdonReadStream } from '../streams/cdon';
|
||||||
|
|
||||||
export function superDecompress<Type>(buffer: ArrayBuffer) {
|
export function superDecompress<Type>(buffer: ArrayBuffer) {
|
||||||
const decompressed = decompress(new Uint8Array(buffer)).buffer;
|
const decompressed = decompress(new Uint8Array(buffer)).buffer as ArrayBuffer;
|
||||||
const read = new CdonReadStream(decompressed);
|
const read = new CdonReadStream(decompressed);
|
||||||
return read.cdon() as Type;
|
return read.cdon() as Type;
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
MessageEditOptions,
|
MessageEditOptions,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { InteractionReturnable } from '../../events/interactionCreate';
|
import { InteractionReturnable } from '../../events/interactionCreate';
|
||||||
|
import { Writeable } from '../../types/writable';
|
||||||
import jsxToPngThreaded from '../blitzkit/jsxToPngThreaded';
|
import jsxToPngThreaded from '../blitzkit/jsxToPngThreaded';
|
||||||
import { RenderConfiguration } from '../blitzkit/renderConfiguration';
|
import { RenderConfiguration } from '../blitzkit/renderConfiguration';
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ export default async function normalizeInteractionReturnable(
|
|||||||
reply.content = item;
|
reply.content = item;
|
||||||
} else if (item instanceof EmbedBuilder) {
|
} else if (item instanceof EmbedBuilder) {
|
||||||
if (!reply.embeds) reply.embeds = [];
|
if (!reply.embeds) reply.embeds = [];
|
||||||
reply.embeds.push(item);
|
(reply.embeds as Writeable<typeof reply.embeds>).push(item);
|
||||||
} else if (item instanceof ButtonBuilder) {
|
} else if (item instanceof ButtonBuilder) {
|
||||||
if (!reply.components)
|
if (!reply.components)
|
||||||
reply.components = [new ActionRowBuilder<ButtonBuilder>()];
|
reply.components = [new ActionRowBuilder<ButtonBuilder>()];
|
||||||
@@ -39,7 +40,7 @@ export default async function normalizeInteractionReturnable(
|
|||||||
);
|
);
|
||||||
} else if (item instanceof AttachmentBuilder) {
|
} else if (item instanceof AttachmentBuilder) {
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
reply.files.push(item);
|
(reply.files as Writeable<typeof reply.files>).push(item);
|
||||||
} else if (item instanceof RenderConfiguration) {
|
} else if (item instanceof RenderConfiguration) {
|
||||||
renderConfiguration = item;
|
renderConfiguration = item;
|
||||||
} else if (item === null) {
|
} else if (item === null) {
|
||||||
@@ -54,7 +55,9 @@ export default async function normalizeInteractionReturnable(
|
|||||||
if (images.length > 0) {
|
if (images.length > 0) {
|
||||||
images.sort(([a], [b]) => b - a);
|
images.sort(([a], [b]) => b - a);
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
images.forEach(([, image]) => reply.files?.push(image));
|
images.forEach(([, image]) =>
|
||||||
|
(reply.files as Writeable<typeof reply.files>)?.push(image),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
|
|||||||
@@ -54,6 +54,6 @@ export class WotbReplayReadStream extends ReadStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const replay = await readFile('temp/test3.wotbreplay');
|
const replay = await readFile('temp/test3.wotbreplay');
|
||||||
const stream = new WotbReplayReadStream(replay.buffer);
|
const stream = new WotbReplayReadStream(replay.buffer as ArrayBuffer);
|
||||||
|
|
||||||
stream.wotbReplay();
|
stream.wotbReplay();
|
||||||
@@ -14,6 +14,7 @@ import normalizeInteractionReturnable from '../../../core/discord/normalizeInter
|
|||||||
import { psa } from '../../../core/discord/psa';
|
import { psa } from '../../../core/discord/psa';
|
||||||
import { translator } from '../../../core/localization/translator';
|
import { translator } from '../../../core/localization/translator';
|
||||||
import { UserError } from '../../../hooks/userError';
|
import { UserError } from '../../../hooks/userError';
|
||||||
|
import { Writeable } from '../../../types/writable';
|
||||||
|
|
||||||
const previewServers = [
|
const previewServers = [
|
||||||
'734786591205359697', // abhi
|
'734786591205359697', // abhi
|
||||||
@@ -69,10 +70,12 @@ export default async function handleChatInputCommand(
|
|||||||
const embed = embedWarning(psa.data.title, psa.data.description);
|
const embed = embedWarning(psa.data.title, psa.data.description);
|
||||||
|
|
||||||
if (psa.data.image) embed.setImage(psa.data.image);
|
if (psa.data.image) embed.setImage(psa.data.image);
|
||||||
reply.embeds.push(embed);
|
(reply.embeds as Writeable<typeof reply.embeds>).push(embed);
|
||||||
} else if (psa.data.type === 'image') {
|
} else if (psa.data.type === 'image') {
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
reply.files.push(new AttachmentBuilder(psa.data.image));
|
(reply.files as Writeable<typeof reply.files>).push(
|
||||||
|
new AttachmentBuilder(psa.data.image),
|
||||||
|
);
|
||||||
reply.content = reply.content ?? psa.data.title;
|
reply.content = reply.content ?? psa.data.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,10 +114,12 @@ export default async function handleChatInputCommand(
|
|||||||
const embed = embedWarning(psa.data.title, psa.data.description);
|
const embed = embedWarning(psa.data.title, psa.data.description);
|
||||||
|
|
||||||
if (psa.data.image) embed.setImage(psa.data.image);
|
if (psa.data.image) embed.setImage(psa.data.image);
|
||||||
followUp.embeds.push(embed);
|
(followUp.embeds as Writeable<typeof followUp.embeds>).push(embed);
|
||||||
} else if (psa.data.type === 'image') {
|
} else if (psa.data.type === 'image') {
|
||||||
if (!followUp.files) followUp.files = [];
|
if (!followUp.files) followUp.files = [];
|
||||||
followUp.files.push(new AttachmentBuilder(psa.data.image));
|
(followUp.files as Writeable<typeof followUp.files>).push(
|
||||||
|
new AttachmentBuilder(psa.data.image),
|
||||||
|
);
|
||||||
followUp.content = followUp.content ?? psa.data.title;
|
followUp.content = followUp.content ?? psa.data.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
RESTPostAPIChatInputApplicationCommandsJSONBody,
|
RESTPostAPIChatInputApplicationCommandsJSONBody,
|
||||||
Routes,
|
Routes,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
|
SlashCommandOptionsOnlyBuilder,
|
||||||
SlashCommandSubcommandsOnlyBuilder,
|
SlashCommandSubcommandsOnlyBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import discord from '../../../discord.json' assert { type: 'json' };
|
import discord from '../../../discord.json' assert { type: 'json' };
|
||||||
@@ -64,6 +65,7 @@ interface CommandRegistryBase {
|
|||||||
command:
|
command:
|
||||||
| SlashCommandBuilder
|
| SlashCommandBuilder
|
||||||
| SlashCommandSubcommandsOnlyBuilder
|
| SlashCommandSubcommandsOnlyBuilder
|
||||||
|
| SlashCommandOptionsOnlyBuilder
|
||||||
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
|
|
||||||
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
||||||
Reference in new issue
Block a user