mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
bigint fixxess
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { eventHandlers } from "../bot.ts";
|
||||
|
||||
export function loopObject(
|
||||
export function loopObject<T = Record<string, unknown>>(
|
||||
obj: Record<string, unknown>,
|
||||
handler: (value: unknown, key: string) => unknown,
|
||||
log: string,
|
||||
@@ -35,5 +35,5 @@ export function loopObject(
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return res as T;
|
||||
}
|
||||
|
||||
+15
-1
@@ -1,5 +1,6 @@
|
||||
import { loopObject } from "../util/loop_object.ts";
|
||||
import { delay } from "../util/utils.ts";
|
||||
import { ws } from "./ws.ts";
|
||||
import { WebSocketRequest, ws } from "./ws.ts";
|
||||
|
||||
export async function processQueue(id: number) {
|
||||
const shard = ws.shards.get(id);
|
||||
@@ -23,6 +24,19 @@ export async function processQueue(id: number) {
|
||||
// Send a request that is next in line
|
||||
const request = shard.queue.shift();
|
||||
|
||||
if (request?.d) {
|
||||
request.d = loopObject(
|
||||
request.d as Record<string, unknown>,
|
||||
(value) =>
|
||||
typeof value === "bigint"
|
||||
? value.toString()
|
||||
: Array.isArray(value)
|
||||
? value.map((v) => typeof v === "bigint" ? v.toString() : v)
|
||||
: value,
|
||||
`Running forEach loop in ws.processQueue function for changing bigints to strings.`,
|
||||
);
|
||||
}
|
||||
|
||||
shard.ws.send(JSON.stringify(request));
|
||||
|
||||
// Counter is useful for preventing 120/m requests.
|
||||
|
||||
+2
-2
@@ -162,8 +162,8 @@ export interface DiscordenoShard {
|
||||
export interface WebSocketRequest {
|
||||
op: DiscordGatewayOpcodes;
|
||||
d: unknown;
|
||||
// guildId: string;
|
||||
// guildId: bigint;
|
||||
// shardId: number;
|
||||
// nonce?: string;
|
||||
// nonce?: bigint;
|
||||
// options?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user