mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 22:16:08 +00:00
feat: getRC client option
This commit is contained in:
parent
2e680f557f
commit
5a53883905
@ -27,7 +27,7 @@ import {
|
|||||||
} from '../common';
|
} from '../common';
|
||||||
|
|
||||||
import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from 'discord-api-types/rest/v10';
|
import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from 'discord-api-types/rest/v10';
|
||||||
import type { DeepPartial, IntentStrings, OmitInsert, PermissionStrings, When } from '../common/types/util';
|
import type { Awaitable, DeepPartial, IntentStrings, OmitInsert, PermissionStrings, When } from '../common/types/util';
|
||||||
import { ComponentHandler } from '../components/handler';
|
import { ComponentHandler } from '../components/handler';
|
||||||
import { LangsHandler } from '../langs/handler';
|
import { LangsHandler } from '../langs/handler';
|
||||||
import type {
|
import type {
|
||||||
@ -85,7 +85,7 @@ export class BaseClient {
|
|||||||
options: BaseClientOptions;
|
options: BaseClientOptions;
|
||||||
|
|
||||||
/**@internal */
|
/**@internal */
|
||||||
static _seyferHttpConfig?: InternalRuntimeConfigHTTP | InternalRuntimeConfig;
|
static _seyferConfig?: InternalRuntimeConfigHTTP | InternalRuntimeConfig;
|
||||||
|
|
||||||
constructor(options?: BaseClientOptions) {
|
constructor(options?: BaseClientOptions) {
|
||||||
this.options = MergeOptions(
|
this.options = MergeOptions(
|
||||||
@ -339,7 +339,8 @@ export class BaseClient {
|
|||||||
async getRC<
|
async getRC<
|
||||||
T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig,
|
T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig,
|
||||||
>() {
|
>() {
|
||||||
const seyfertConfig = (BaseClient._seyferHttpConfig ||
|
const seyfertConfig = (BaseClient._seyferConfig ||
|
||||||
|
(await this.options.getRC?.()) ||
|
||||||
(await magicImport(join(process.cwd(), 'seyfert.config.js')).then(x => x.default ?? x))) as T;
|
(await magicImport(join(process.cwd(), 'seyfert.config.js')).then(x => x.default ?? x))) as T;
|
||||||
|
|
||||||
const { locations, debug, ...env } = seyfertConfig;
|
const { locations, debug, ...env } = seyfertConfig;
|
||||||
@ -357,7 +358,7 @@ export class BaseClient {
|
|||||||
output: join(process.cwd(), locations.output),
|
output: join(process.cwd(), locations.output),
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseClient._seyferHttpConfig = seyfertConfig;
|
BaseClient._seyferConfig = seyfertConfig;
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -404,6 +405,7 @@ export interface BaseClientOptions {
|
|||||||
allowedMentions?: Omit<NonNullable<RESTPostAPIChannelMessageJSONBody['allowed_mentions']>, 'parse'> & {
|
allowedMentions?: Omit<NonNullable<RESTPostAPIChannelMessageJSONBody['allowed_mentions']>, 'parse'> & {
|
||||||
parse?: ('everyone' | 'roles' | 'users')[]; //nice types, d-api
|
parse?: ('everyone' | 'roles' | 'users')[]; //nice types, d-api
|
||||||
};
|
};
|
||||||
|
getRC?(): Awaitable<InternalRuntimeConfig | InternalRuntimeConfigHTTP>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StartOptions {
|
export interface StartOptions {
|
||||||
|
@ -86,7 +86,7 @@ export const config = {
|
|||||||
port: 8080,
|
port: 8080,
|
||||||
...data,
|
...data,
|
||||||
} as InternalRuntimeConfigHTTP;
|
} as InternalRuntimeConfigHTTP;
|
||||||
if (isCloudfareWorker()) BaseClient._seyferHttpConfig = obj;
|
if (isCloudfareWorker()) BaseClient._seyferConfig = obj;
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user