diff --git a/src/client/base.ts b/src/client/base.ts index ddb5760..53da335 100644 --- a/src/client/base.ts +++ b/src/client/base.ts @@ -223,7 +223,6 @@ export class BaseClient { this.langs = undefined; } else if (typeof handlers.langs === 'function') { this.langs ??= new LangsHandler(this.logger); - this.langs.setHandlers({ callback: handlers.langs }); } else { this.langs = handlers.langs; } @@ -492,7 +491,7 @@ export interface ServicesOptions { handlers?: { components?: ComponentHandler | ComponentHandler['callback']; commands?: CommandHandler; - langs?: LangsHandler | LangsHandler['callback']; + langs?: LangsHandler; }; handleCommand?: typeof HandleCommand; } diff --git a/src/langs/handler.ts b/src/langs/handler.ts index 2990c87..6fa4667 100644 --- a/src/langs/handler.ts +++ b/src/langs/handler.ts @@ -1,6 +1,7 @@ import type { Locale, LocaleString } from 'discord-api-types/v10'; import { BaseHandler } from '../common'; import { LangRouter } from './router'; +import type { FileLoaded } from '../commands/handler'; export class LangsHandler extends BaseHandler { values: Partial> = {}; @@ -40,14 +41,12 @@ export class LangsHandler extends BaseHandler { const files = instances ?? (await this.loadFilesK>(await this.getFiles(dir))); for (const i of files) { const locale = i.name.split('.').slice(0, -1).join('.') || i.name; - const result = this.callback(locale, i.file); + const result = this.onFile(locale, i.file); if (result) this.values[locale] = result; } } - setHandlers({ callback }: { callback: LangsHandler['callback'] }) { - this.callback = callback; + onFile(_locale: string, file: FileLoaded>): Record | false { + return file.default ?? false; } - - callback = (_locale: string, file: Record): Record | false => file; }