Commit 3197900a authored by nanahira's avatar nanahira

support command def on top class

parent cb530e14
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"schemastery": "^2.1.2", "schemastery": "^2.1.2",
"schemastery-gen": "^2.3.1", "schemastery-gen": "^2.3.1",
"typed-reflector": "^1.0.8" "typed-reflector": "^1.0.9"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0", "@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0",
...@@ -6441,9 +6441,9 @@ ...@@ -6441,9 +6441,9 @@
} }
}, },
"node_modules/typed-reflector": { "node_modules/typed-reflector": {
"version": "1.0.8", "version": "1.0.9",
"resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.8.tgz", "resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.9.tgz",
"integrity": "sha512-Gc2y1jdXpBrRDhTth80ABcmZjL/4Jmx+GrBf7uvn4BXW4J+kj5V3IjA+GQl/n+3ye7SgoEO6HOiDhac1H+mKgw==", "integrity": "sha512-Df9KpLcXsSM4/q+iFT/WKU8RxmwUC8POY/7VFL9xgvqh2aaY7o+43n7pUTUVKtimJTkQokKoOVe/B8ouW8tBhA==",
"dependencies": { "dependencies": {
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"
} }
...@@ -11654,9 +11654,9 @@ ...@@ -11654,9 +11654,9 @@
} }
}, },
"typed-reflector": { "typed-reflector": {
"version": "1.0.8", "version": "1.0.9",
"resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.8.tgz", "resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.9.tgz",
"integrity": "sha512-Gc2y1jdXpBrRDhTth80ABcmZjL/4Jmx+GrBf7uvn4BXW4J+kj5V3IjA+GQl/n+3ye7SgoEO6HOiDhac1H+mKgw==", "integrity": "sha512-Df9KpLcXsSM4/q+iFT/WKU8RxmwUC8POY/7VFL9xgvqh2aaY7o+43n7pUTUVKtimJTkQokKoOVe/B8ouW8tBhA==",
"requires": { "requires": {
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"
} }
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"schemastery": "^2.1.2", "schemastery": "^2.1.2",
"schemastery-gen": "^2.3.1", "schemastery-gen": "^2.3.1",
"typed-reflector": "^1.0.8" "typed-reflector": "^1.0.9"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [
......
...@@ -134,7 +134,9 @@ export const OnSelection = (selection: Selection) => ...@@ -134,7 +134,9 @@ export const OnSelection = (selection: Selection) =>
// Command definition // Command definition
export const CommandDef = (def: CommandDefinitionFun): MethodDecorator => export const CommandDef = (
def: CommandDefinitionFun,
): MethodDecorator & ClassDecorator =>
Metadata.append(KoishiCommandDefinition, def); Metadata.append(KoishiCommandDefinition, def);
export const CommandDescription = (desc: string) => export const CommandDescription = (desc: string) =>
......
...@@ -269,10 +269,11 @@ export function DefinePlugin<T = any>( ...@@ -269,10 +269,11 @@ export function DefinePlugin<T = any>(
commandData.desc, commandData.desc,
commandData.config, commandData.config,
); );
const commandDefs = reflector.getArray( const commandDefs = reflector.getProperty(
KoishiCommandDefinition, KoishiCommandDefinition,
this, this,
methodKey, methodKey,
originalClass,
); );
for (const commandDef of commandDefs) { for (const commandDef of commandDefs) {
command = commandDef(command) || command; command = commandDef(command) || command;
......
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