diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index 8c70501f5..0c74df574 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -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((resolve) => { ), ) .setMinValue(0); - }) as SlashCommandBuilder, + }), async handler(interaction) { const { translate } = translator(interaction.locale); diff --git a/src/core/blitz/extractArmor.ts b/src/core/blitz/extractArmor.ts index 9ccf7f76c..db5302dae 100644 --- a/src/core/blitz/extractArmor.ts +++ b/src/core/blitz/extractArmor.ts @@ -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(); diff --git a/src/core/blitz/extractModel/index.ts b/src/core/blitz/extractModel/index.ts index fa49d4ac3..4020f00d2 100644 --- a/src/core/blitz/extractModel/index.ts +++ b/src/core/blitz/extractModel/index.ts @@ -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(); diff --git a/src/core/blitzkit/fetchCdonLz4.ts b/src/core/blitzkit/fetchCdonLz4.ts index 0fbf1e4db..762631533 100644 --- a/src/core/blitzkit/fetchCdonLz4.ts +++ b/src/core/blitzkit/fetchCdonLz4.ts @@ -3,5 +3,5 @@ import { superDecompress } from './superDecompress'; export async function fetchCdonLz4(url: string) { return await fetch(url, { cache: 'no-store' }) .then((response) => response.arrayBuffer()) - .then((buffer) => superDecompress(new Uint8Array(buffer))); + .then((buffer) => superDecompress(buffer)); } diff --git a/src/core/blitzkit/getArchivedRatingInfo.ts b/src/core/blitzkit/getArchivedRatingInfo.ts index cfe85020e..c4d92ec36 100644 --- a/src/core/blitzkit/getArchivedRatingInfo.ts +++ b/src/core/blitzkit/getArchivedRatingInfo.ts @@ -27,9 +27,7 @@ export default async function getArchivedRatingInfo( ) .then((response) => response.arrayBuffer()) .then((buffer) => - superDecompress( - new Uint8Array(buffer), - ), + superDecompress(buffer), ); cache[region][season] = info; } diff --git a/src/core/blitzkit/readTexture/index.ts b/src/core/blitzkit/readTexture/index.ts index 3c42af572..eb64496d2 100644 --- a/src/core/blitzkit/readTexture/index.ts +++ b/src/core/blitzkit/readTexture/index.ts @@ -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: { diff --git a/src/core/blitzkit/superDecompress.ts b/src/core/blitzkit/superDecompress.ts index 697bab1de..5cf1881f4 100644 --- a/src/core/blitzkit/superDecompress.ts +++ b/src/core/blitzkit/superDecompress.ts @@ -2,7 +2,7 @@ import { decompress } from 'lz4js'; import { CdonReadStream } from '../streams/cdon'; export function superDecompress(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; } diff --git a/src/core/discord/normalizeInteractionReturnable.ts b/src/core/discord/normalizeInteractionReturnable.ts index 2ae4ce76a..a6532f2e6 100644 --- a/src/core/discord/normalizeInteractionReturnable.ts +++ b/src/core/discord/normalizeInteractionReturnable.ts @@ -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).push(item); } else if (item instanceof ButtonBuilder) { if (!reply.components) reply.components = [new ActionRowBuilder()]; @@ -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).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)?.push(image), + ); } return reply; diff --git a/src/core/streams/wotbreplay.ts b/src/core/streams/wotbreplay.ts index 0d996ad86..07a25ebbd 100644 --- a/src/core/streams/wotbreplay.ts +++ b/src/core/streams/wotbreplay.ts @@ -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(); diff --git a/src/events/interactionCreate/handlers/chatInputCommand.ts b/src/events/interactionCreate/handlers/chatInputCommand.ts index 6b111128f..2e1fffa43 100644 --- a/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -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).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).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).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).push( + new AttachmentBuilder(psa.data.image), + ); followUp.content = followUp.content ?? psa.data.title; } diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 9732ffdf7..64b179583 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -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; autocomplete?: (interaction: AutocompleteInteraction) => void; diff --git a/src/types/writable.ts b/src/types/writable.ts new file mode 100644 index 000000000..2f45b1129 --- /dev/null +++ b/src/types/writable.ts @@ -0,0 +1 @@ +export type Writeable = { -readonly [P in keyof T]: T[P] };