diff --git a/src/embed-builders/card.ts b/src/embed-builders/card.ts index bfe6d70..33c22d7 100644 --- a/src/embed-builders/card.ts +++ b/src/embed-builders/card.ts @@ -1,9 +1,7 @@ -import { chromium } from "playwright"; +import { browser } from "index"; import type { CardBuilderOptions } from "@type/embedBuilders"; import type { MessageReplyOptions } from "@lilybird/transformers"; -const browser = await chromium.launch(); - export async function cardBuilder({ user }: CardBuilderOptions): Promise { const now = performance.now(); diff --git a/src/index.ts b/src/index.ts index 79cccb8..0c826dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { createHandler } from "@lilybird/handlers/simple"; import { CachingDelegationType, createClient, Intents } from "lilybird"; import { Channel, Guild, GuildVoiceChannel } from "@lilybird/transformers"; import { $ } from "bun"; +import { chromium } from "playwright"; import { writeFile } from "node:fs/promises"; // refresh token every hour @@ -16,6 +17,13 @@ async function setToken(): Promise { await setToken(); +// make sure chromium is dead +try { + await $`pkill chromium && pkill chromium-browser`; +} catch (e) {} + +export const browser = await chromium.launch(); + process.on("unhandledRejection", async (error: Error) => { await loadLogs(`ERROR: uncaught exception: ${error.stack}`, true); }); @@ -51,8 +59,3 @@ await createClient({ ...listeners }); -// make sure chromium is dead -try { - await $`pkill chromium && pkill chromium-browser`; -} catch (e) {} -