From 24f77185664cde7a2f64dc7d195a2fc5825f9524 Mon Sep 17 00:00:00 2001 From: ITOH Date: Fri, 27 May 2022 23:48:04 +0200 Subject: [PATCH] feat!: make createBot sync (#2255) --- bot.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bot.ts b/bot.ts index 1ee3ef547..6e0c0a6dc 100644 --- a/bot.ts +++ b/bot.ts @@ -140,7 +140,7 @@ import { transformComponentToDiscordComponent } from "./transformers/reverse/com import { getBotIdFromToken, removeTokenPrefix } from "./util/token.ts"; import { CreateShardManager } from "./gateway/manager/shardManager.ts"; -export async function createBot(options: CreateBotOptions): Promise { +export function createBot(options: CreateBotOptions): Bot { const bot = { id: options.botId ?? getBotIdFromToken(options.token), applicationId: options.applicationId || options.botId, @@ -168,7 +168,7 @@ export async function createBot(options: CreateBotOptions): Promise { bot.helpers = createHelpers(bot, options.helpers ?? {}); bot.gateway = createGatewayManager({ - gatewayBot: bot.botGatewayData ?? await bot.helpers.getGatewayBot(), + gatewayBot: bot.botGatewayData ?? {} as any, gatewayConfig: { token: options.token, intents: options.intents, @@ -259,7 +259,11 @@ export function createEventHandlers( }; } -export function startBot(bot: Bot) { +export async function startBot(bot: Bot) { + if (!bot.botGatewayData) { + bot.gateway.gatewayBot = await bot.helpers.getGatewayBot(); + } + bot.gateway.spawnShards(); }