This commit is contained in:
Skillz
2020-10-26 11:39:09 -04:00
parent be9b78b326
commit 9f943cb4a2

View File

@@ -1,4 +1,12 @@
import { RequestManager, DiscordBotGatewayData, spawnShards } from "../../mod.ts";
import { endpoints } from "../constants/discord.ts";
import { ClientOptions } from "../types/options.ts";
import { botGatewayData, identifyPayload } from "./client.ts";
const botOptions = {
token: "",
eventHandlers: {}
}
/**
* This function should be used only by bot developers whose bots are in over 25,000 servers.
@@ -7,7 +15,22 @@ import { ClientOptions } from "../types/options.ts";
* Advanced Devs: This function will allow you to have an insane amount of customization potential as when you get to large bots you need to be able to optimize every tiny detail to make you bot work the way you need.
*/
export async function startHugeBot(data: HugeBotOptions) {
botOptions.token = `Bot ${data.token}`;
if (data.eventHandlers) botOptions.eventHandlers = data.eventHandlers;
// Initial API connection to get info about bots connection
botGatewayData = await RequestManager.get(
endpoints.GATEWAY_BOT,
) as DiscordBotGatewayData;
identifyPayload.token = data.token;
identifyPayload.intents = data.intents.reduce(
(bits, next) => (bits |= next),
0,
);
identifyPayload.shard = [0, botGatewayData.shards];
spawnShards(botGatewayData, identifyPayload);
}
export interface HugeBotOptions extends ClientOptions {