fix: startBot overriding dispatch event handler

This commit is contained in:
ITOH
2021-06-05 22:24:09 +02:00
parent 814025de48
commit 5131095290

View File

@@ -12,12 +12,16 @@ export let secretKey = "";
export let botId = 0n;
export let applicationId = 0n;
export let eventHandlers: EventHandlers = { dispatchRequirements };
export let eventHandlers: EventHandlers = {};
export let proxyWSURL = `wss://gateway.discord.gg`;
export async function startBot(config: BotConfig) {
if (config.eventHandlers) eventHandlers = config.eventHandlers;
if (config.eventHandlers)
eventHandlers = {
...config.eventHandlers,
dispatchRequirements: config.eventHandlers.dispatchRequirements || dispatchRequirements,
};
ws.identifyPayload.token = `Bot ${config.token}`;
rest.token = `Bot ${config.token}`;
ws.identifyPayload.intents = config.intents.reduce(