mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
import type fixes
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
import {
|
||||
DiscordBotGatewayData,
|
||||
GatewayOpcode,
|
||||
ReadyPayload,
|
||||
} from "../types/discord.ts";
|
||||
import {
|
||||
eventHandlers,
|
||||
botGatewayData,
|
||||
IdentifyPayload,
|
||||
} from "./client.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import type { DiscordBotGatewayData, ReadyPayload } from "../types/discord.ts";
|
||||
import type { IdentifyPayload } from "./client.ts";
|
||||
import {
|
||||
connectWebSocket,
|
||||
isWebSocketCloseEvent,
|
||||
WebSocket,
|
||||
} from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
import { DiscordHeartbeatPayload } from "../types/discord.ts";
|
||||
import { logRed } from "../utils/logger.ts";
|
||||
import type { DiscordHeartbeatPayload } from "../types/discord.ts";
|
||||
import type { FetchMembersOptions } from "../types/guild.ts";
|
||||
import type { BotStatusRequest } from "../utils/utils.ts";
|
||||
|
||||
import { handleDiscordPayload } from "./shardingManager.ts";
|
||||
import { FetchMembersOptions } from "../types/guild.ts";
|
||||
import { BotStatusRequest } from "../utils/utils.ts";
|
||||
import { logRed } from "../utils/logger.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import { GatewayOpcode } from "../types/discord.ts";
|
||||
import {
|
||||
eventHandlers,
|
||||
botGatewayData,
|
||||
} from "./client.ts";
|
||||
|
||||
const basicShards = new Map<number, BasicShard>();
|
||||
const heartbeating = new Set<number>();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
import { DiscordBotGatewayData } from "../types/discord.ts";
|
||||
import { ClientOptions, EventHandlers } from "../types/options.ts";
|
||||
import { RequestManager } from "./requestManager.ts";
|
||||
import type { ClientOptions, EventHandlers } from "../types/options.ts";
|
||||
import type { DiscordBotGatewayData } from "../types/discord.ts";
|
||||
|
||||
import { spawnShards } from "./shardingManager.ts";
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
import { RequestManager } from "./requestManager.ts";
|
||||
|
||||
export let authorization = "";
|
||||
export let botID = "";
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { RequestMethod } from "../types/fetch.ts";
|
||||
import { authorization, eventHandlers } from "./client.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import { Errors } from "../types/errors.ts";
|
||||
import { HttpResponseCode } from "../types/discord.ts";
|
||||
import { logRed } from "../utils/logger.ts";
|
||||
import { authorization, eventHandlers } from "./client.ts";
|
||||
import { baseEndpoints } from "../constants/discord.ts";
|
||||
import type { RequestMethods } from "../types/fetch.ts";
|
||||
|
||||
import { Errors } from "../types/errors.ts";
|
||||
import { logRed } from "../utils/logger.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
|
||||
const pathQueues: { [key: string]: QueuedRequest[] } = {};
|
||||
const ratelimitedPaths = new Map<string, RateLimitedPath>();
|
||||
@@ -121,23 +122,23 @@ processRateLimitedPaths();
|
||||
|
||||
export const RequestManager = {
|
||||
get: async (url: string, body?: unknown) => {
|
||||
return runMethod(RequestMethod.Get, url, body);
|
||||
return runMethod("get", url, body);
|
||||
},
|
||||
post: (url: string, body?: unknown) => {
|
||||
return runMethod(RequestMethod.Post, url, body);
|
||||
return runMethod("post", url, body);
|
||||
},
|
||||
delete: (url: string, body?: unknown) => {
|
||||
return runMethod(RequestMethod.Delete, url, body);
|
||||
return runMethod("delete", url, body);
|
||||
},
|
||||
patch: (url: string, body?: unknown) => {
|
||||
return runMethod(RequestMethod.Patch, url, body);
|
||||
return runMethod("patch", url, body);
|
||||
},
|
||||
put: (url: string, body?: unknown) => {
|
||||
return runMethod(RequestMethod.Put, url, body);
|
||||
return runMethod("put", url, body);
|
||||
},
|
||||
};
|
||||
|
||||
function createRequestBody(body: any, method: RequestMethod) {
|
||||
function createRequestBody(body: any, method: RequestMethods) {
|
||||
const headers: { [key: string]: string } = {
|
||||
Authorization: authorization,
|
||||
"User-Agent":
|
||||
@@ -156,7 +157,7 @@ function createRequestBody(body: any, method: RequestMethod) {
|
||||
form.append("payload_json", JSON.stringify({ ...body, file: undefined }));
|
||||
body.file = form;
|
||||
} else if (
|
||||
body && ![RequestMethod.Get, RequestMethod.Delete].includes(method)
|
||||
body && !["get", "delete"].includes(method)
|
||||
) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
@@ -184,7 +185,7 @@ async function checkRatelimits(url: string) {
|
||||
}
|
||||
|
||||
async function runMethod(
|
||||
method: RequestMethod,
|
||||
method: RequestMethods,
|
||||
url: string,
|
||||
body?: unknown,
|
||||
retryCount = 0,
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import {
|
||||
connectWebSocket,
|
||||
isWebSocketCloseEvent,
|
||||
WebSocket,
|
||||
} from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
import {
|
||||
GatewayOpcode,
|
||||
import type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
import type {
|
||||
DiscordBotGatewayData,
|
||||
DiscordHeartbeatPayload,
|
||||
ReadyPayload,
|
||||
} from "../types/discord.ts";
|
||||
import type { FetchMembersOptions } from "../types/guild.ts";
|
||||
import type { DebugArg } from "../types/options.ts";
|
||||
|
||||
import { GatewayOpcode } from "../types/discord.ts";
|
||||
import { logRed } from "../utils/logger.ts";
|
||||
import { FetchMembersOptions } from "../types/guild.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import { DebugArg } from "../types/options.ts";
|
||||
import {
|
||||
connectWebSocket,
|
||||
isWebSocketCloseEvent,
|
||||
} from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
|
||||
let shardSocket: WebSocket;
|
||||
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import {
|
||||
import type { IdentifyPayload } from "./client.ts";
|
||||
import type { Guild } from "../structures/guild.ts";
|
||||
import type { FetchMembersOptions } from "../types/guild.ts";
|
||||
import type {
|
||||
DiscordBotGatewayData,
|
||||
DiscordPayload,
|
||||
GatewayOpcode,
|
||||
} from "../types/discord.ts";
|
||||
import {
|
||||
eventHandlers,
|
||||
botGatewayData,
|
||||
identifyPayload,
|
||||
IdentifyPayload,
|
||||
} from "./client.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import { Guild } from "../structures/guild.ts";
|
||||
import {
|
||||
FetchMembersOptions,
|
||||
} from "../types/guild.ts";
|
||||
import type { BotStatusRequest } from "../utils/utils.ts";
|
||||
|
||||
import { controllers } from "../controllers/mod.ts";
|
||||
import { cache } from "../utils/cache.ts";
|
||||
import {
|
||||
createBasicShard,
|
||||
requestGuildMembers,
|
||||
botGatewayStatusRequest,
|
||||
} from "./basicShard.ts";
|
||||
import { BotStatusRequest } from "../utils/utils.ts";
|
||||
import { controllers } from "../controllers/mod.ts";
|
||||
import {
|
||||
eventHandlers,
|
||||
botGatewayData,
|
||||
identifyPayload,
|
||||
} from "./client.ts";
|
||||
import { GatewayOpcode } from "../types/discord.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
|
||||
let shardCounter = 0;
|
||||
let basicSharding = false;
|
||||
|
||||
Reference in New Issue
Block a user