diff --git a/src/api/middlewares/botOnline.ts b/src/api/middlewares/botOnline.ts index 4b8f3009..4bcdf2f5 100644 --- a/src/api/middlewares/botOnline.ts +++ b/src/api/middlewares/botOnline.ts @@ -1,23 +1,23 @@ import { Middleware } from "@tsed/common" import { InternalServerError } from "@tsed/exceptions" -import axios from "axios" - -import { apiConfig } from "@configs" - -const baseUrl = `http://127.0.0.1:${apiConfig.port}` +import { resolveDependencies } from "@utils/functions" +import { Client } from "discordx" @Middleware() export class BotOnline { - async use() { + private client: Client + + constructor() { - const { data } = await axios.get(`${baseUrl}/health/check`, { - params: { - logIgnore: true - } + resolveDependencies([Client]).then(([client]) => { + this.client = client }) - - if (!data?.online) throw new InternalServerError('Bot is offline') + } + + async use() { + + if (this.client.user?.presence.status === 'offline') throw new InternalServerError('Bot is offline') } } \ No newline at end of file