@globalart/nestcord 1.7.6 → 1.7.8

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.
@@ -48,7 +48,7 @@ let CommandsModule = class CommandsModule {
48
48
  const { skipGetCommandInfoFromDiscord, skipRegistration } = this.options;
49
49
  if (!skipGetCommandInfoFromDiscord) {
50
50
  yield this.client.application.commands.fetch();
51
- this.commandsService.getAllCommandsAndSetAdditionalMeta();
51
+ this.commandsService.getAllCommandsAndSetDiscordResponseMeta();
52
52
  }
53
53
  if (!skipRegistration) {
54
54
  if (this.client.application.partial) {
@@ -56,7 +56,7 @@ let CommandsModule = class CommandsModule {
56
56
  }
57
57
  yield this.commandsService.registerAllCommands();
58
58
  if (!skipGetCommandInfoFromDiscord) {
59
- this.commandsService.getAllCommandsAndSetAdditionalMeta();
59
+ this.commandsService.getAllCommandsAndSetDiscordResponseMeta();
60
60
  }
61
61
  }
62
62
  });
@@ -25,10 +25,11 @@ export declare class CommandsService {
25
25
  getCommandsByGuilds(): Collection<string, CommandDiscovery[]>;
26
26
  getCommandsByCategoryMap(): Map<string, CommandDiscovery[]>;
27
27
  getCommandsMap(): Map<string, CommandDiscovery>;
28
+ getGuildCommandsMap(guildId: string): Map<string, CommandDiscovery<import("./command.discovery").BaseCommandMeta>>;
28
29
  getCommandByName(name: string): CommandDiscovery;
29
30
  getGlobalCommands(): CommandDiscovery[];
30
31
  getGlobalCommandByName(name: string): CommandDiscovery;
31
32
  getGuildCommands(guildId: string): CommandDiscovery[];
32
33
  getGuildCommandByName(guildId: string, name: string): CommandDiscovery;
33
- getAllCommandsAndSetAdditionalMeta(): void;
34
+ getAllCommandsAndSetDiscordResponseMeta(): void;
34
35
  }
@@ -95,6 +95,12 @@ let CommandsService = CommandsService_1 = class CommandsService {
95
95
  return map;
96
96
  }, new Map());
97
97
  }
98
+ getGuildCommandsMap(guildId) {
99
+ return this.getGuildCommands(guildId).reduce((map, command) => {
100
+ map.set(command.getName(), command);
101
+ return map;
102
+ }, new Map());
103
+ }
98
104
  getCommandByName(name) {
99
105
  return this.getCommands().find((command) => command.getName() === name);
100
106
  }
@@ -102,15 +108,15 @@ let CommandsService = CommandsService_1 = class CommandsService {
102
108
  return this.getCommandsByGuilds().get(undefined) || [];
103
109
  }
104
110
  getGlobalCommandByName(name) {
105
- return this.getGlobalCommands().find((command) => command.getName() === name);
111
+ return this.getCommandsMap().get(name);
106
112
  }
107
113
  getGuildCommands(guildId) {
108
114
  return this.getCommandsByGuilds().get(guildId) || [];
109
115
  }
110
116
  getGuildCommandByName(guildId, name) {
111
- return this.getGuildCommands(guildId).find((command) => command.getName() === name);
117
+ return this.getGuildCommandsMap(guildId).get(name);
112
118
  }
113
- getAllCommandsAndSetAdditionalMeta() {
119
+ getAllCommandsAndSetDiscordResponseMeta() {
114
120
  const commands = this.getCommandsMap();
115
121
  const commandsCache = this.client.application.commands.cache;
116
122
  const matchingCommands = Array.from(commandsCache.values()).filter((command) => commands.has(command.name));
@@ -24,7 +24,6 @@ var LocalizationInterceptor_1;
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.LocalizationInterceptor = void 0;
26
26
  const common_1 = require("@nestjs/common");
27
- const operators_1 = require("rxjs/operators");
28
27
  const core_1 = require("../../../core");
29
28
  const providers_1 = require("../providers");
30
29
  const adapters_1 = require("../adapters");
@@ -60,11 +59,7 @@ let LocalizationInterceptor = LocalizationInterceptor_1 = class LocalizationInte
60
59
  const locale = yield this.getLocale(nestcordContext);
61
60
  const translationFn = this.getTranslationFn(locale);
62
61
  LocalizationInterceptor_1.currentTranslationFn = translationFn;
63
- return next.handle().pipe((0, operators_1.tap)({
64
- finalize: () => {
65
- LocalizationInterceptor_1.currentTranslationFn = null;
66
- },
67
- }));
62
+ return next.handle();
68
63
  });
69
64
  }
70
65
  getLocale(ctx) {
@@ -5,10 +5,12 @@ import { PageBuilder } from './page.builder';
5
5
  export declare class SelectMenuPaginationBuilder extends BasePaginationBuilder {
6
6
  private items;
7
7
  private pages;
8
+ private customOptions;
8
9
  setPages(data: {
9
10
  pageId: string;
10
11
  builder: PageBuilder;
11
12
  }[]): this;
13
+ setCustomOptions(value: string): void;
12
14
  private getPagesMap;
13
15
  setSelectMenuItems(value: MenuAppearance[]): this;
14
16
  build(page: string): Promise<PageOptions>;
@@ -23,6 +23,9 @@ class SelectMenuPaginationBuilder extends base_pagination_builder_1.BasePaginati
23
23
  this.pages = data;
24
24
  return this;
25
25
  }
26
+ setCustomOptions(value) {
27
+ this.customOptions = value;
28
+ }
26
29
  getPagesMap() {
27
30
  return new Map(this.pages.map(({ pageId, builder }) => [pageId, builder]));
28
31
  }
@@ -42,7 +45,9 @@ class SelectMenuPaginationBuilder extends base_pagination_builder_1.BasePaginati
42
45
  });
43
46
  }
44
47
  createMenuItems(items) {
45
- return new discord_js_1.StringSelectMenuBuilder().setCustomId(`nestcord-pagination/${this.customId}`).addOptions(items);
48
+ return new discord_js_1.StringSelectMenuBuilder()
49
+ .setCustomId(`nestcord-pagination/${this.customId}/${this.customOptions || ''}`)
50
+ .addOptions(items);
46
51
  }
47
52
  }
48
53
  exports.SelectMenuPaginationBuilder = SelectMenuPaginationBuilder;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalart/nestcord",
3
3
  "description": "A module for creating Discord bots using NestJS, based on Discord.js",
4
- "version": "1.7.6",
4
+ "version": "1.7.8",
5
5
  "private": false,
6
6
  "scripts": {
7
7
  "build": "rimraf dist && tsc -p tsconfig.build.json",
@@ -61,10 +61,10 @@
61
61
  "@nestjs/common": "10.3.9",
62
62
  "@nestjs/core": "10.3.9",
63
63
  "@nestjs/platform-express": "^10.3.8",
64
- "@types/node": "20.14.8",
64
+ "@types/node": "20.14.9",
65
65
  "@typescript-eslint/eslint-plugin": "7.0.0",
66
66
  "@typescript-eslint/parser": "6.21.0",
67
- "discord-api-types": "0.37.90",
67
+ "discord-api-types": "0.37.91",
68
68
  "discord.js": "14.15.3",
69
69
  "eslint": "8.57.0",
70
70
  "eslint-config-prettier": "9.1.0",