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