necord 4.2.0 → 4.2.1

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.
@@ -1,3 +1,3 @@
1
1
  import { Type } from '@nestjs/common';
2
2
  import { TransformOptions } from '../interfaces';
3
- export declare const Autocomplete: (autocomplete: Type<TransformOptions>) => MethodDecorator;
3
+ export declare const Autocomplete: (...autocompletes: Type<TransformOptions>[]) => MethodDecorator;
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Autocomplete = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const necord_constants_1 = require("../necord.constants");
6
- const Autocomplete = (autocomplete) => (0, common_1.SetMetadata)(necord_constants_1.AUTOCOMPLETE_METADATA, autocomplete);
6
+ const Autocomplete = (...autocompletes) => (0, common_1.SetMetadata)(necord_constants_1.AUTOCOMPLETE_METADATA, autocompletes);
7
7
  exports.Autocomplete = Autocomplete;
@@ -53,10 +53,11 @@ let NecordInteractionUpdate = NecordInteractionUpdate_1 = class NecordInteractio
53
53
  for (const [guild, commands] of commandsByGuildMap.entries()) {
54
54
  const registeredCommands = yield clientCommands.set(commands, guild);
55
55
  const fullPermissions = commands.map(command => {
56
+ var _a;
56
57
  const applicationCommand = registeredCommands.find(x => x.name === command.name);
57
58
  return {
58
59
  id: applicationCommand.id,
59
- permissions: command.metadata[necord_constants_1.PERMISSIONS_METADATA]
60
+ permissions: (_a = command.metadata[necord_constants_1.PERMISSIONS_METADATA]) !== null && _a !== void 0 ? _a : []
60
61
  };
61
62
  });
62
63
  if (guild) {
@@ -107,24 +108,29 @@ let NecordInteractionUpdate = NecordInteractionUpdate_1 = class NecordInteractio
107
108
  return command.metadata.execute([interaction], this.transformOptions(command, interaction), { type: 'slashCommands' });
108
109
  }
109
110
  const module = command.metadata.host;
110
- const autocompleteMetadata = command.metadata[necord_constants_1.AUTOCOMPLETE_METADATA];
111
+ const instances = command.metadata[necord_constants_1.AUTOCOMPLETE_METADATA];
111
112
  const { instance: moduleRef } = module.getProviderByKey(core_1.ModuleRef);
112
- if (!module || !autocompleteMetadata || !moduleRef)
113
+ if (!module || !instances || !moduleRef)
113
114
  return;
114
- const getAutocomplete = () => __awaiter(this, void 0, void 0, function* () {
115
- const provider = module.getProviderByKey(autocompleteMetadata);
115
+ const getAutocomplete = (instance) => __awaiter(this, void 0, void 0, function* () {
116
+ const provider = module.getProviderByKey(instance);
116
117
  if (provider) {
117
118
  return provider.instance;
118
119
  }
119
120
  module.addProvider({
120
- provide: autocompleteMetadata,
121
- useValue: yield moduleRef.create(autocompleteMetadata)
121
+ provide: instance,
122
+ useValue: yield moduleRef.create(instance)
122
123
  });
123
- return getAutocomplete();
124
+ return getAutocomplete(instance);
124
125
  });
125
- let autocomplete = yield getAutocomplete();
126
- const options = yield autocomplete.transformOptions(interaction, interaction.options.getFocused(true));
127
- return interaction.respond(options !== null && options !== void 0 ? options : []);
126
+ for (const instance of instances) {
127
+ const autocomplete = yield getAutocomplete(instance);
128
+ const options = yield (autocomplete === null || autocomplete === void 0 ? void 0 : autocomplete.transformOptions(interaction, interaction.options.getFocused(true)));
129
+ if (!options || !Array.isArray(options))
130
+ continue;
131
+ return interaction.respond(options);
132
+ }
133
+ return interaction.respond([]);
128
134
  }
129
135
  });
130
136
  }
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.2.0",
4
+ "version": "4.2.1",
5
5
  "scripts": {
6
6
  "build": "rimraf -rf dist && tsc -p tsconfig.json",
7
7
  "prepublish:npm": "npm run build",