diff --git a/packages/collection/src/index.ts b/packages/collection/src/index.ts index a2bb42852..5ab8f277f 100644 --- a/packages/collection/src/index.ts +++ b/packages/collection/src/index.ts @@ -185,7 +185,7 @@ export class Collection extends Map { if (!arr.length || !amount) return []; return Array.from( { length: Math.min(amount, arr.length) }, - (): V => arr.splice(Math.floor(Math.random() * arr.length), 1)[0], + (): V => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!, ); } @@ -204,7 +204,7 @@ export class Collection extends Map { if (!arr.length || !amount) return []; return Array.from( { length: Math.min(amount, arr.length) }, - (): K => arr.splice(Math.floor(Math.random() * arr.length), 1)[0], + (): K => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!, ); } diff --git a/packages/rest/src/lib/RequestManager.ts b/packages/rest/src/lib/RequestManager.ts index 7d0bd1da6..2ffd0dfe9 100644 --- a/packages/rest/src/lib/RequestManager.ts +++ b/packages/rest/src/lib/RequestManager.ts @@ -481,7 +481,7 @@ export class RequestManager extends EventEmitter { // Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket) // https://github.com/discord/discord-api-docs/issues/1295 if (method === RequestMethod.Delete && baseRoute === '/channels/:id/messages/:id') { - const id = /\d{16,19}$/.exec(endpoint)![0]; + const id = /\d{16,19}$/.exec(endpoint)![0]!; const timestamp = DiscordSnowflake.timestampFrom(id); if (Date.now() - timestamp > 1000 * 60 * 60 * 24 * 14) { exceptions += '/Delete Old Message'; diff --git a/packages/voice/src/audio/AudioResource.ts b/packages/voice/src/audio/AudioResource.ts index 1db0c1abb..5866d3d98 100644 --- a/packages/voice/src/audio/AudioResource.ts +++ b/packages/voice/src/audio/AudioResource.ts @@ -97,7 +97,7 @@ export class AudioResource { public constructor(edges: readonly Edge[], streams: readonly Readable[], metadata: T, silencePaddingFrames: number) { this.edges = edges; - this.playStream = streams.length > 1 ? (pipeline(streams, noop) as any as Readable) : streams[0]; + this.playStream = streams.length > 1 ? (pipeline(streams, noop) as any as Readable) : streams[0]!; this.metadata = metadata; this.silencePaddingFrames = silencePaddingFrames; diff --git a/packages/voice/src/networking/VoiceUDPSocket.ts b/packages/voice/src/networking/VoiceUDPSocket.ts index 992508c26..0b60922cf 100644 --- a/packages/voice/src/networking/VoiceUDPSocket.ts +++ b/packages/voice/src/networking/VoiceUDPSocket.ts @@ -133,7 +133,7 @@ export class VoiceUDPSocket extends TypedEmitter { const counter = buffer.readUInt32LE(0); const index = this.keepAlives.findIndex(({ value }) => value === counter); if (index === -1) return; - this.ping = Date.now() - this.keepAlives[index].timestamp; + this.ping = Date.now() - this.keepAlives[index]!.timestamp; // Delete all keep alives up to and including the received one this.keepAlives.splice(0, index); } diff --git a/packages/voice/src/receive/VoiceReceiver.ts b/packages/voice/src/receive/VoiceReceiver.ts index 0d06ea68d..1d1b5b9fe 100644 --- a/packages/voice/src/receive/VoiceReceiver.ts +++ b/packages/voice/src/receive/VoiceReceiver.ts @@ -134,7 +134,7 @@ export class VoiceReceiver { const headerExtensionLength = packet.readUInt16BE(2); let offset = 4; for (let i = 0; i < headerExtensionLength; i++) { - const byte = packet[offset]; + const byte = packet[offset]!; offset++; if (byte === 0) continue; offset += 1 + (byte >> 4); diff --git a/tsconfig.json b/tsconfig.json index d1d5a8993..28c62d99b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "noUnusedParameters": true, "strict": true, "useUnknownInCatchVariables": true, + "noUncheckedIndexedAccess": true, // Modules "module": "CommonJS",