necord 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,12 @@ exports.MentionableOption = createNecordOptionDecorator('MENTIONABLE', 'getMenti
14
14
  exports.AttachmentOption = createNecordOptionDecorator('ATTACHMENT', 'getAttachment');
15
15
  function createNecordOptionDecorator(type, methodName) {
16
16
  return (data) => (target, propertyKey) => {
17
- var _a;
18
- const options = (_a = Reflect.getMetadata(necord_constants_1.OPTIONS_METADATA, target.constructor)) !== null && _a !== void 0 ? _a : {};
19
- options[propertyKey] = Object.assign(Object.assign({}, data), { type,
20
- methodName });
21
- Reflect.defineMetadata(necord_constants_1.OPTIONS_METADATA, options, target.constructor);
17
+ Reflect.defineProperty(target, propertyKey, {
18
+ value: undefined,
19
+ writable: true,
20
+ configurable: true
21
+ });
22
+ Reflect.defineMetadata(necord_constants_1.OPTIONS_METADATA, Object.assign(Object.assign({}, data), { type,
23
+ methodName }), target, propertyKey);
22
24
  };
23
25
  }
@@ -7,9 +7,21 @@ const params_util_1 = require("./params.util");
7
7
  exports.Context = (0, params_util_1.createNecordParamDecorator)(context_1.NecordParamType.CONTEXT);
8
8
  exports.Options = (0, params_util_1.createNecordPipesParamDecorator)(context_1.NecordParamType.OPTIONS, [
9
9
  (target, propertyKey, parameterIndex) => {
10
- const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);
11
- const options = Reflect.getMetadata(necord_constants_1.OPTIONS_METADATA, paramTypes[parameterIndex]);
12
- Reflect.defineMetadata(necord_constants_1.OPTIONS_METADATA, options, target[propertyKey]);
10
+ try {
11
+ const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);
12
+ let prototype = Reflect.getPrototypeOf(new paramTypes[parameterIndex]());
13
+ const options = {};
14
+ for (; prototype !== Object.prototype; prototype = Reflect.getPrototypeOf(prototype)) {
15
+ Object.getOwnPropertyNames(prototype)
16
+ .map(name => [name, Reflect.getMetadata(necord_constants_1.OPTIONS_METADATA, prototype, name)])
17
+ .filter(([, meta]) => !!meta)
18
+ .forEach(([name, meta]) => { var _a; return ((_a = options[name]) !== null && _a !== void 0 ? _a : (options[name] = meta)); });
19
+ }
20
+ Reflect.defineMetadata(necord_constants_1.OPTIONS_METADATA, options, target[propertyKey]);
21
+ }
22
+ catch (err) {
23
+ // NO-OP
24
+ }
13
25
  }
14
26
  ]);
15
27
  exports.Info = (0, params_util_1.createNecordPipesParamDecorator)(context_1.NecordParamType.INFO);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "necord",
3
3
  "description": "A module for creating Discord bots using NestJS, based on Discord.js.",
4
- "version": "4.3.1",
4
+ "version": "4.3.2",
5
5
  "scripts": {
6
6
  "build": "rimraf -rf dist && tsc -p tsconfig.json",
7
7
  "prepublish:npm": "npm run build",