remove: startBigBrainBot

This commit is contained in:
ITOH
2021-05-13 19:30:26 +02:00
parent c0c1ef4512
commit 68fef1d74c

View File

@@ -61,76 +61,9 @@ export function setApplicationId(id: string) {
applicationId = snowflakeToBigint(id);
}
// BIG BRAIN BOT STUFF ONLY BELOW THIS
/**
* This function should be used only by bot developers whose bots are in over 25,000 servers.
* Please be aware if you are a beginner developer using this, things will not work as per the guides. This is for advanced developers only!
*
* 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 startBigBrainBot(options: BigBrainBotConfig) {
rest.token = `Bot ${options.token}`;
if (options.secretKey) secretKey = options.secretKey;
if (options.restURL) baseEndpoints.BASE_URL = options.restURL;
if (options.cdnURL) baseEndpoints.CDN_URL = options.cdnURL;
if (options.eventHandlers) eventHandlers = options.eventHandlers;
// PROXY DOESNT NEED US SPAWNING SHARDS
if (!options.wsPort) {
ws.identifyPayload.token = `Bot ${options.token}`;
if (options.compress) {
ws.identifyPayload.compress = options.compress;
}
ws.identifyPayload.intents = options.intents.reduce(
(
bits,
next,
) => (bits |= typeof next === "string"
? DiscordGatewayIntents[next]
: next),
0,
);
// Initial API connection to get info about bots connection
ws.botGatewayData = await getGatewayBot();
ws.maxShards = ws.maxShards ||
ws.botGatewayData.shards;
ws.lastShardId = options.lastShardId || (ws.lastShardId === 1
? 0
: ws.lastShardId) ||
ws.botGatewayData.shards - 1;
// Explicitly append gateway version and encoding
ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`;
proxyWSURL = ws.botGatewayData.url;
ws.spawnShards(options.firstShardId);
}
}
export interface BotConfig {
token: string;
compress?: boolean;
intents: (DiscordGatewayIntents | keyof typeof DiscordGatewayIntents)[];
eventHandlers?: EventHandlers;
}
export interface BigBrainBotConfig extends BotConfig {
/** The first shard to start at for this worker. Use this to control which shards to run in each worker. */
firstShardId: number;
/** The last shard to start for this worker. By default it will be 25 + the firstShardId. */
lastShardId?: number;
/** The maximum shard Id number. Useful for zero-downtime updates or resharding. */
maxShards?: number;
/** This can be used to forward the ws handling to a proxy. It will disable the sharding done by the bot side. */
wsPort?: number;
/** This can be used to forward the REST handling to a proxy. */
restURL?: string;
/** This can be used to forward the CDN handling to a proxy. */
cdnURL?: string;
/** This is the authorization header that your servers will send. Helpful to prevent DDOS attacks and such. */
secretKey?: string;
}