Commit 4cc90c3b authored by nanahira's avatar nanahira

work on readme

parent b8ac1588
Pipeline #6143 passed with stages
in 1 minute and 31 seconds
This diff is collapsed.
{
"name": "koishi-nestjs",
"version": "1.0.23",
"version": "1.0.24",
"description": "Koishi.js as Nest.js Module",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
......@@ -30,8 +30,8 @@
"author": "Nanahira",
"license": "MIT",
"peerDependencies": {
"@nestjs/common": "^7.0.0 || ^8.0.0",
"@nestjs/core": "^7.0.0 || ^8.0.0",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"koishi": "^4.0.0-alpha.9",
"proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13"
......
......@@ -44,7 +44,7 @@ export class KoishiMetascanService {
);
if (instanceContextFilters) {
for (const filter of instanceContextFilters) {
baseContext = filter(baseContext);
baseContext = filter(baseContext) || baseContext;
}
}
const methodContextFilters: OnContextFunction[] = this.reflector.get(
......@@ -53,7 +53,7 @@ export class KoishiMetascanService {
);
if (methodContextFilters) {
for (const filter of methodContextFilters) {
baseContext = filter(baseContext);
baseContext = filter(baseContext) || baseContext;
}
}
console.log(regData);
......@@ -65,9 +65,8 @@ export class KoishiMetascanService {
);
break;
case 'onevent':
const {
data: eventData,
} = regData as DoRegisterConfig<EventNameAndPrepend>;
const { data: eventData } =
regData as DoRegisterConfig<EventNameAndPrepend>;
baseContext.on(eventData.name, (...args: any[]) =>
methodFun.call(instance, ...args),
);
......@@ -76,6 +75,9 @@ export class KoishiMetascanService {
const pluginDesc: KoishiModulePlugin<any> = await methodFun.call(
instance,
);
if (!pluginDesc || !pluginDesc.plugin) {
throw new Error(`Invalid plugin from method ${methodKey}.`);
}
const pluginCtx = pluginDesc.select
? baseContext.select(pluginDesc.select)
: baseContext.any();
......@@ -85,10 +87,9 @@ export class KoishiMetascanService {
const { data: commandData } = regData as DoRegisterConfig<
ContextFunction<Command>
>;
let command = commandData(
baseContext,
).action((argv: Argv, ...args: any[]) =>
methodFun.call(instance, argv, ...args),
let command = commandData(baseContext).action(
(argv: Argv, ...args: any[]) =>
methodFun.call(instance, argv, ...args),
);
const commandDefs: CommandDefinitionFun[] = this.reflector.get(
KoishiCommandDefinition,
......@@ -96,7 +97,7 @@ export class KoishiMetascanService {
);
if (commandDefs) {
for (const commandDef of commandDefs) {
command = commandDef(command);
command = commandDef(command) || command;
}
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment