From 9f943cb4a232fae21c8f3bf2dac42c43cb0ab863 Mon Sep 17 00:00:00 2001 From: Skillz Date: Mon, 26 Oct 2020 11:39:09 -0400 Subject: [PATCH] work --- src/module/hugebot.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/module/hugebot.ts b/src/module/hugebot.ts index 8acddedb7..2ce8e0740 100644 --- a/src/module/hugebot.ts +++ b/src/module/hugebot.ts @@ -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 {