From fcd9ffd34d654ccf14909226fa9964ee1b85fab3 Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Sun, 15 Sep 2024 06:00:46 +0000 Subject: [PATCH] fix: reuse proxy --- src/client/base.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/base.ts b/src/client/base.ts index fe26741..61c60b6 100644 --- a/src/client/base.ts +++ b/src/client/base.ts @@ -1,5 +1,5 @@ import { join } from 'node:path'; -import { ApiHandler, Router } from '../api'; +import { ApiHandler, Router, type APIRoutes } from '../api'; import type { Adapter } from '../cache'; import { Cache, MemoryAdapter } from '../cache'; import type { @@ -57,6 +57,7 @@ import type { MessageStructure } from './transformers'; export class BaseClient { rest!: ApiHandler; + proxy!: APIRoutes; cache!: Cache; applications = new ApplicationShorter(this); @@ -184,13 +185,10 @@ export class BaseClient { return this._applicationId ?? this.botId; } - get proxy() { - return new Router(this.rest).createProxy(); - } - setServices({ rest, cache, langs, middlewares, handleCommand }: ServicesOptions) { if (rest) { this.rest = rest; + this.proxy = new Router(this.rest).createProxy(); } if (cache) { const caches: (keyof Cache['disabledCache'])[] = [ @@ -275,6 +273,7 @@ export class BaseClient { domain: 'https://discord.com', debug, }); + this.proxy = new Router(this.rest).createProxy(); } if (this.cache) {