necord 5.2.0 → 5.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [5.2.0](https://github.com/necordjs/necord/compare/v5.1.0...v5.2.0) - (2022-08-11)
5
+
6
+ ## Features
7
+
8
+ - Add get guilds method and guilds property (#352) ([487caf2](https://github.com/necordjs/necord/commit/487caf2fdefed98c558518f5fedcac63cb4f528d))
9
+
4
10
  # [5.1.0](https://github.com/necordjs/necord/compare/v5.0.3...v5.1.0) - (2022-07-31)
5
11
 
6
12
  ## Bug Fixes
@@ -4,5 +4,5 @@ export declare const ChannelOption: (data: {
4
4
  name_localizations?: Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
5
5
  description_localizations?: Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
6
6
  required?: boolean;
7
- channel_types?: (import("discord.js").ChannelType.GuildText | import("discord.js").ChannelType.GuildVoice | import("discord.js").ChannelType.GuildCategory | import("discord.js").ChannelType.GuildNews | import("discord.js").ChannelType.GuildNewsThread | import("discord.js").ChannelType.GuildPublicThread | import("discord.js").ChannelType.GuildPrivateThread | import("discord.js").ChannelType.GuildStageVoice | import("discord.js").ChannelType.GuildDirectory | import("discord.js").ChannelType.GuildForum)[];
7
+ channel_types?: (import("discord.js").ChannelType.GuildText | import("discord.js").ChannelType.GuildVoice | import("discord.js").ChannelType.GuildCategory | import("discord.js").ChannelType.GuildAnnouncement | import("discord.js").ChannelType.AnnouncementThread | import("discord.js").ChannelType.PublicThread | import("discord.js").ChannelType.PrivateThread | import("discord.js").ChannelType.GuildStageVoice | import("discord.js").ChannelType.GuildDirectory | import("discord.js").ChannelType.GuildForum)[];
8
8
  }) => PropertyDecorator;
@@ -1,2 +1,3 @@
1
1
  export * from './fields.decorator';
2
2
  export * from './modal.decorator';
3
+ export * from './modal-param.decorator';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./fields.decorator"), exports);
18
18
  __exportStar(require("./modal.decorator"), exports);
19
+ __exportStar(require("./modal-param.decorator"), exports);
@@ -0,0 +1 @@
1
+ export declare const ModalParam: (...dataOrPipes: any[]) => ParameterDecorator;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModalParam = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const context_1 = require("../../context");
6
+ const v10_1 = require("discord-api-types/v10");
7
+ exports.ModalParam = (0, common_1.createParamDecorator)((data, ctx) => {
8
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
9
+ const [interaction] = necordContext.getContext();
10
+ const discovery = necordContext.getDiscovery();
11
+ if (!discovery.isModal() || interaction.type !== v10_1.InteractionType.ModalSubmit)
12
+ return null;
13
+ const match = discovery.matcher(interaction.customId);
14
+ if (!match)
15
+ return null;
16
+ return data ? match.params[data] : match.params;
17
+ });
@@ -4,6 +4,7 @@ export interface ModalMeta {
4
4
  customId: string;
5
5
  }
6
6
  export declare class ModalDiscovery extends NecordBaseDiscovery<ModalMeta> {
7
+ readonly matcher: import("path-to-regexp").MatchFunction<object>;
7
8
  getCustomId(): string;
8
9
  execute(interaction: ModalSubmitInteraction): any;
9
10
  isModal(): this is ModalDiscovery;
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModalDiscovery = void 0;
4
4
  const context_1 = require("../context");
5
+ const path_to_regexp_1 = require("path-to-regexp");
5
6
  class ModalDiscovery extends context_1.NecordBaseDiscovery {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.matcher = (0, path_to_regexp_1.match)(this.meta.customId);
10
+ }
6
11
  getCustomId() {
7
12
  return this.meta.customId;
8
13
  }
@@ -18,19 +18,23 @@ let ModalsService = class ModalsService {
18
18
  constructor(client, explorerService) {
19
19
  this.client = client;
20
20
  this.explorerService = explorerService;
21
- this.modals = new Map();
21
+ this.modals = [];
22
22
  }
23
23
  onModuleInit() {
24
24
  return this.explorerService
25
25
  .explore(necord_constants_1.MODAL_METADATA)
26
- .forEach(modal => this.modals.set(modal.getCustomId(), modal));
26
+ .forEach(modal => this.modals.push(modal));
27
27
  }
28
28
  onApplicationBootstrap() {
29
29
  return this.client.on('interactionCreate', interaction => {
30
- var _a;
31
30
  if (interaction.type !== discord_js_1.InteractionType.ModalSubmit)
32
31
  return;
33
- return (_a = this.modals.get(interaction.customId)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
32
+ const name = interaction.customId;
33
+ for (const modal of this.modals) {
34
+ if (modal.matcher(name)) {
35
+ return modal.execute(interaction);
36
+ }
37
+ }
34
38
  });
35
39
  }
36
40
  };
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": "5.2.0",
4
+ "version": "5.3.0",
5
5
  "scripts": {
6
6
  "build": "rimraf -rf dist && tsc -p tsconfig.json",
7
7
  "prepublish:npm": "npm run build",
@@ -51,33 +51,33 @@
51
51
  "path-to-regexp": "6.2.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@commitlint/cli": "17.0.3",
55
- "@commitlint/config-angular": "17.0.3",
54
+ "@commitlint/cli": "17.1.2",
55
+ "@commitlint/config-angular": "17.1.0",
56
56
  "@favware/npm-deprecate": "1.0.5",
57
57
  "@nestjs/common": "8.4.7",
58
58
  "@nestjs/core": "8.4.7",
59
- "@types/node": "18.6.5",
60
- "@typescript-eslint/eslint-plugin": "5.33.0",
61
- "@typescript-eslint/parser": "5.33.0",
62
- "discord-api-types": "0.37.1",
63
- "discord.js": "14.1.2",
64
- "eslint": "8.21.0",
59
+ "@types/node": "18.7.18",
60
+ "@typescript-eslint/eslint-plugin": "5.37.0",
61
+ "@typescript-eslint/parser": "5.37.0",
62
+ "discord-api-types": "0.37.10",
63
+ "discord.js": "14.3.0",
64
+ "eslint": "8.23.1",
65
65
  "eslint-config-prettier": "8.5.0",
66
66
  "eslint-plugin-prettier": "4.2.1",
67
67
  "husky": "8.0.1",
68
- "jest": "28.1.3",
68
+ "jest": "29.0.3",
69
69
  "lint-staged": "13.0.3",
70
70
  "prettier": "2.7.1",
71
71
  "reflect-metadata": "0.1.13",
72
- "release-it": "15.3.0",
72
+ "release-it": "15.4.2",
73
73
  "rimraf": "3.0.2",
74
74
  "rxjs": "7.5.6",
75
75
  "ts-node": "10.9.1",
76
- "typescript": "4.7.4"
76
+ "typescript": "4.8.3"
77
77
  },
78
78
  "peerDependencies": {
79
- "@nestjs/common": "^8.0.0",
80
- "@nestjs/core": "^8.0.0",
79
+ "@nestjs/common": "^8.0.0 || ^9.0.0",
80
+ "@nestjs/core": "^8.0.0 || ^9.0.0",
81
81
  "discord.js": "^14.0.1",
82
82
  "reflect-metadata": "^0.1.13",
83
83
  "rxjs": "^7.2.0"