diff --git a/packages/localizer/index.ts b/packages/localizer/index.ts index f2bc42e..689990b 100644 --- a/packages/localizer/index.ts +++ b/packages/localizer/index.ts @@ -93,10 +93,10 @@ export const localize = (root?: string) => dfsApplyLocalization(module.options ?? [], deps, [resolvedRoot]); //@ts-ignore return controller.next({ - locals: { - name_localizations: localizer.translationsFor(resolvedRoot+".name"), - description_localizations: localizer.translationsFor(resolvedRoot+'.description') - } + locals: { + nloc: localizer.translationsFor(resolvedRoot+".name"), + dloc: localizer.translationsFor(resolvedRoot+'.description') + } }); } else { //@ts-ignore diff --git a/packages/publisher/index.mdx b/packages/publisher/index.mdx index 2d89e25..d1cd15b 100644 --- a/packages/publisher/index.mdx +++ b/packages/publisher/index.mdx @@ -19,7 +19,7 @@ NODE_ENV= **Initializing the Publisher** ```ts import { makeDependencies } from '@sern/handler'; -import { Publisher } from '@sern/localizer'; +import { Publisher } from '@sern/publisher'; await makeDependencies(({ add }) => { add('publisher', new Publisher()); @@ -52,6 +52,9 @@ type ValidPublishOptions = | PublishConfig | (absPath: string, module: CommandModule) => PublishConfig ``` +:::tip +These types are exported under @sern/publisher +::: ### Example: command published with integrationTypes diff --git a/packages/publisher/index.ts b/packages/publisher/index.ts index 8281bcc..7a779bd 100644 --- a/packages/publisher/index.ts +++ b/packages/publisher/index.ts @@ -25,7 +25,7 @@ const makeDescription = (type: number, desc: string) => { return desc; }; -const serializePermissions = (perms: unknown) => { +const serializePerms = (perms: unknown) => { if(typeof perms === 'bigint' || typeof perms === 'number') { return perms.toString(); } @@ -85,17 +85,12 @@ export class Publisher implements Init { //@ts-ignore shutup options: optionsTransformer(module?.options), default_member_permissions, - integration_types: integration_types.map( - (s: string) => { - if(s === "Guild") return "0"; - else if (s == "User") return "1"; - else throw Error("IntegrationType is not one of Guild or User"); - }), + integration_types, contexts, //@ts-ignore - name_localizations: module.locals.name_localizations, + name_localizations: module.locals.nloc, //@ts-ignore - description_localizations: module.locals.description_localizations + description_localizations: module.locals.dloc } } } @@ -195,6 +190,9 @@ export type ValidPublishOptions = | PublishConfig | ((absPath: string, module: CommandModule) => PublishConfig) +const IntegrationType = { + Guild: '0', User: '1' +} /** * the publishConfig plugin. * If your commandModule requires extra properties such as publishing for certain guilds, you would @@ -211,15 +209,15 @@ export const publishConfig = (config: ValidPublishOptions) => { if(typeof _config === 'function') { _config = _config(absPath, module); } - const { contexts, defaultMemberPermissions, integrationTypes } = _config + const { contexts, defaultMemberPermissions, integrationTypes:integration_types, guildIds } = _config //@ts-ignore return controller.next({ locals: { publish: { - guildIds: _config.guildIds, - default_member_permissions: serializePermissions(defaultMemberPermissions), - integration_types: integrationTypes, - contexts + guildIds, + contexts, + integration_types: integration_types?.map(i => Reflect.get(IntegrationType, i)), + default_member_permissions: serializePerms(defaultMemberPermissions), } } });