necord 6.13.0 → 7.0.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/dist/commands/command.discovery.d.ts +3 -3
- package/dist/commands/command.discovery.js +2 -6
- package/dist/commands/commands.module.d.ts +4 -4
- package/dist/commands/commands.module.js +23 -22
- package/dist/commands/commands.service.d.ts +8 -7
- package/dist/commands/commands.service.js +24 -18
- package/dist/commands/context-menus/context-menu.discovery.d.ts +3 -3
- package/dist/commands/context-menus/context-menu.discovery.js +2 -6
- package/dist/commands/context-menus/context-menus.module.d.ts +4 -4
- package/dist/commands/context-menus/context-menus.module.js +16 -19
- package/dist/commands/context-menus/context-menus.service.d.ts +2 -2
- package/dist/commands/context-menus/context-menus.service.js +8 -11
- package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +1 -1
- package/dist/commands/context-menus/decorators/context-menu.decorator.js +4 -7
- package/dist/commands/context-menus/decorators/index.d.ts +4 -4
- package/dist/commands/context-menus/decorators/index.js +4 -7
- package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +2 -2
- package/dist/commands/context-menus/decorators/message-command.decorator.js +3 -7
- package/dist/commands/context-menus/decorators/target.decorator.js +8 -11
- package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +2 -2
- package/dist/commands/context-menus/decorators/user-command.decorator.js +3 -7
- package/dist/commands/context-menus/index.d.ts +4 -4
- package/dist/commands/context-menus/index.js +4 -7
- package/dist/commands/index.d.ts +5 -5
- package/dist/commands/index.js +5 -8
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +1 -1
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +9 -12
- package/dist/commands/slash-commands/autocomplete/index.d.ts +1 -1
- package/dist/commands/slash-commands/autocomplete/index.js +1 -4
- package/dist/commands/slash-commands/decorators/index.d.ts +3 -3
- package/dist/commands/slash-commands/decorators/index.js +3 -6
- package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +2 -2
- package/dist/commands/slash-commands/decorators/slash-command.decorator.js +6 -9
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +3 -3
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +13 -17
- package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +2 -2
- package/dist/commands/slash-commands/decorators/subcommand.decorator.js +6 -9
- package/dist/commands/slash-commands/index.d.ts +6 -6
- package/dist/commands/slash-commands/index.js +6 -9
- package/dist/commands/slash-commands/options/attachment-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/boolean-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/channel-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/index.d.ts +12 -12
- package/dist/commands/slash-commands/options/index.js +12 -15
- package/dist/commands/slash-commands/options/integer-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/member-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/mentionable-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/number-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/option.util.d.ts +2 -2
- package/dist/commands/slash-commands/options/option.util.js +5 -10
- package/dist/commands/slash-commands/options/options.decorator.js +22 -14
- package/dist/commands/slash-commands/options/role-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/string-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/user-option.decorator.js +3 -6
- package/dist/commands/slash-commands/slash-command.discovery.d.ts +5 -34
- package/dist/commands/slash-commands/slash-command.discovery.js +7 -10
- package/dist/commands/slash-commands/slash-commands.module.d.ts +4 -4
- package/dist/commands/slash-commands/slash-commands.module.js +17 -20
- package/dist/commands/slash-commands/slash-commands.service.d.ts +3 -3
- package/dist/commands/slash-commands/slash-commands.service.js +16 -16
- package/dist/context/decorators/context.decorator.js +4 -7
- package/dist/context/decorators/discovery.decorator.js +3 -6
- package/dist/context/decorators/index.d.ts +2 -2
- package/dist/context/decorators/index.js +2 -5
- package/dist/context/decorators/params.util.d.ts +1 -1
- package/dist/context/decorators/params.util.js +8 -8
- package/dist/context/index.d.ts +7 -7
- package/dist/context/index.js +7 -10
- package/dist/context/necord-arguments-host.d.ts +3 -3
- package/dist/context/necord-arguments-host.js +2 -6
- package/dist/context/necord-base.discovery.d.ts +6 -6
- package/dist/context/necord-base.discovery.js +3 -7
- package/dist/context/necord-context.interface.d.ts +1 -1
- package/dist/context/necord-context.interface.js +1 -2
- package/dist/context/necord-execution-context.d.ts +1 -1
- package/dist/context/necord-execution-context.js +2 -6
- package/dist/context/necord-params.factory.d.ts +3 -3
- package/dist/context/necord-params.factory.js +4 -8
- package/dist/context/necord-paramtype.enum.js +2 -5
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -15
- package/dist/listeners/decorators/custom-listener.decorator.js +3 -6
- package/dist/listeners/decorators/index.d.ts +4 -4
- package/dist/listeners/decorators/index.js +4 -7
- package/dist/listeners/decorators/listener.decorator.d.ts +1 -1
- package/dist/listeners/decorators/listener.decorator.js +4 -7
- package/dist/listeners/decorators/on.decorator.d.ts +2 -2
- package/dist/listeners/decorators/on.decorator.js +4 -8
- package/dist/listeners/decorators/once.decorator.d.ts +2 -2
- package/dist/listeners/decorators/once.decorator.js +4 -8
- package/dist/listeners/handlers/base.handler.d.ts +1 -1
- package/dist/listeners/handlers/base.handler.js +7 -11
- package/dist/listeners/handlers/channel-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/channel-update.handler.js +14 -17
- package/dist/listeners/handlers/guild-audit-log-entry-create.handler.d.ts +2 -2
- package/dist/listeners/handlers/guild-audit-log-entry-create.handler.js +19 -22
- package/dist/listeners/handlers/guild-member-update.handler.d.ts +14 -6
- package/dist/listeners/handlers/guild-member-update.handler.js +46 -39
- package/dist/listeners/handlers/guild-update.handler.d.ts +8 -4
- package/dist/listeners/handlers/guild-update.handler.js +34 -37
- package/dist/listeners/handlers/index.d.ts +11 -11
- package/dist/listeners/handlers/index.js +11 -14
- package/dist/listeners/handlers/message-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/message-update.handler.js +19 -22
- package/dist/listeners/handlers/presence-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/presence-update.handler.js +15 -18
- package/dist/listeners/handlers/role-update.handler.d.ts +5 -5
- package/dist/listeners/handlers/role-update.handler.js +24 -27
- package/dist/listeners/handlers/thread-update.handler.d.ts +6 -6
- package/dist/listeners/handlers/thread-update.handler.js +34 -37
- package/dist/listeners/handlers/user-update.handler.d.ts +6 -6
- package/dist/listeners/handlers/user-update.handler.js +34 -37
- package/dist/listeners/handlers/voice-state-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/voice-state-update.handler.js +47 -34
- package/dist/listeners/index.d.ts +6 -6
- package/dist/listeners/index.js +6 -9
- package/dist/listeners/listener.discovery.d.ts +2 -2
- package/dist/listeners/listener.discovery.js +2 -6
- package/dist/listeners/listener.interface.d.ts +1 -1
- package/dist/listeners/listener.interface.js +1 -2
- package/dist/listeners/listeners.module.d.ts +4 -4
- package/dist/listeners/listeners.module.js +28 -28
- package/dist/listeners/scopes/async-custom-listener.context.d.ts +1 -1
- package/dist/listeners/scopes/async-custom-listener.context.js +6 -10
- package/dist/listeners/scopes/index.d.ts +1 -1
- package/dist/listeners/scopes/index.js +1 -4
- package/dist/message-components/decorators/button.decorator.js +3 -7
- package/dist/message-components/decorators/component-param.decorator.js +4 -7
- package/dist/message-components/decorators/index.d.ts +5 -5
- package/dist/message-components/decorators/index.js +5 -8
- package/dist/message-components/decorators/message-component.decorator.d.ts +1 -1
- package/dist/message-components/decorators/message-component.decorator.js +4 -7
- package/dist/message-components/decorators/select-menu.decorator.js +7 -15
- package/dist/message-components/decorators/selected.decorator.js +17 -20
- package/dist/message-components/index.d.ts +4 -4
- package/dist/message-components/index.js +4 -7
- package/dist/message-components/message-component.discovery.d.ts +1 -1
- package/dist/message-components/message-component.discovery.js +4 -8
- package/dist/message-components/message-components.module.d.ts +4 -4
- package/dist/message-components/message-components.module.js +16 -19
- package/dist/message-components/message-components.service.d.ts +2 -2
- package/dist/message-components/message-components.service.js +8 -11
- package/dist/modals/decorators/fields.decorator.js +4 -7
- package/dist/modals/decorators/index.d.ts +3 -3
- package/dist/modals/decorators/index.js +3 -6
- package/dist/modals/decorators/modal-param.decorator.js +4 -7
- package/dist/modals/decorators/modal.decorator.d.ts +1 -1
- package/dist/modals/decorators/modal.decorator.js +4 -7
- package/dist/modals/index.d.ts +4 -4
- package/dist/modals/index.js +4 -7
- package/dist/modals/modal.discovery.d.ts +1 -1
- package/dist/modals/modal.discovery.js +4 -8
- package/dist/modals/modals.module.d.ts +4 -4
- package/dist/modals/modals.module.js +16 -19
- package/dist/modals/modals.service.d.ts +2 -2
- package/dist/modals/modals.service.js +8 -11
- package/dist/necord-context.creator.d.ts +1 -1
- package/dist/necord-context.creator.js +29 -24
- package/dist/necord-explorer.service.d.ts +2 -2
- package/dist/necord-explorer.service.js +28 -21
- package/dist/necord-options.interface.d.ts +4 -0
- package/dist/necord-options.interface.js +1 -2
- package/dist/necord.module-definition.d.ts +1 -1
- package/dist/necord.module-definition.js +3 -7
- package/dist/necord.module.d.ts +4 -4
- package/dist/necord.module.js +35 -38
- package/dist/providers/channels.provider.d.ts +1 -1
- package/dist/providers/channels.provider.js +4 -7
- package/dist/providers/client.provider.js +6 -9
- package/dist/providers/guilds.provider.d.ts +1 -1
- package/dist/providers/guilds.provider.js +4 -7
- package/dist/providers/index.d.ts +8 -8
- package/dist/providers/index.js +8 -11
- package/dist/providers/rest.provider.js +4 -7
- package/dist/providers/shard.provider.d.ts +2 -2
- package/dist/providers/shard.provider.js +4 -7
- package/dist/providers/users.provider.d.ts +1 -1
- package/dist/providers/users.provider.js +4 -7
- package/dist/providers/voice.provider.d.ts +1 -1
- package/dist/providers/voice.provider.js +4 -7
- package/dist/providers/ws.provider.d.ts +1 -1
- package/dist/providers/ws.provider.js +4 -7
- package/dist/scopes/async.context.d.ts +1 -1
- package/dist/scopes/async.context.js +10 -14
- package/dist/scopes/index.d.ts +1 -1
- package/dist/scopes/index.js +1 -4
- package/dist/text-commands/decorators/arguments.decorator.js +5 -8
- package/dist/text-commands/decorators/index.d.ts +2 -2
- package/dist/text-commands/decorators/index.js +2 -5
- package/dist/text-commands/decorators/text-command.decorator.d.ts +1 -1
- package/dist/text-commands/decorators/text-command.decorator.js +4 -7
- package/dist/text-commands/index.d.ts +4 -4
- package/dist/text-commands/index.js +4 -7
- package/dist/text-commands/text-command.discovery.d.ts +3 -1
- package/dist/text-commands/text-command.discovery.js +5 -6
- package/dist/text-commands/text-commands.module.d.ts +6 -6
- package/dist/text-commands/text-commands.module.js +29 -24
- package/dist/text-commands/text-commands.service.d.ts +2 -2
- package/dist/text-commands/text-commands.service.js +16 -12
- package/package.json +42 -33
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -8
- package/.release-it.json +0 -74
- package/CHANGELOG.md +0 -461
- package/coverage/clover.xml +0 -1794
- package/coverage/coverage-final.json +0 -113
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -431
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -3295
- package/eslint.config.mjs +0 -53
- package/jest.config.json +0 -16
- package/tsconfig.json +0 -30
package/dist/modals/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./modal.discovery"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./modals.module"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./modals.service"), exports);
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './modal.discovery.js';
|
|
3
|
+
export * from './modals.module.js';
|
|
4
|
+
export * from './modals.service.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ModalDiscovery = void 0;
|
|
4
|
-
const context_1 = require("../context");
|
|
5
|
-
const path_to_regexp_1 = require("path-to-regexp");
|
|
1
|
+
import { match } from 'path-to-regexp';
|
|
2
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Represents a modal discovery.
|
|
8
5
|
*/
|
|
9
|
-
class ModalDiscovery extends
|
|
6
|
+
export class ModalDiscovery extends NecordBaseDiscovery {
|
|
10
7
|
constructor() {
|
|
11
8
|
super(...arguments);
|
|
12
|
-
this.matcher =
|
|
9
|
+
this.matcher = match(this.meta.customId);
|
|
13
10
|
}
|
|
14
11
|
getCustomId() {
|
|
15
12
|
return this.meta.customId;
|
|
@@ -24,4 +21,3 @@ class ModalDiscovery extends context_1.NecordBaseDiscovery {
|
|
|
24
21
|
return this.meta;
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
exports.ModalDiscovery = ModalDiscovery;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { ModalsService } from './modals.service';
|
|
3
2
|
import { Client } from 'discord.js';
|
|
4
|
-
import { NecordExplorerService } from '../necord-explorer.service';
|
|
5
|
-
import { ModalDiscovery } from './modal.discovery';
|
|
6
|
-
|
|
3
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
4
|
+
import { ModalDiscovery } from './modal.discovery.js';
|
|
5
|
+
import { ModalsService } from './modals.service.js';
|
|
6
|
+
export declare class ModalsModule implements OnApplicationBootstrap, OnModuleInit {
|
|
7
7
|
private readonly client;
|
|
8
8
|
private readonly explorerService;
|
|
9
9
|
private readonly modalsService;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const decorators_1 = require("./decorators");
|
|
8
|
-
const discord_js_1 = require("discord.js");
|
|
9
|
-
const necord_explorer_service_1 = require("../necord-explorer.service");
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Global, Module } from '@nestjs/common';
|
|
3
|
+
import { Client } from 'discord.js';
|
|
4
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
5
|
+
import { ModalsService } from './modals.service.js';
|
|
6
|
+
import { Modal } from './decorators/index.js';
|
|
10
7
|
let ModalsModule = class ModalsModule {
|
|
11
8
|
constructor(client, explorerService, modalsService) {
|
|
12
9
|
this.client = client;
|
|
@@ -15,7 +12,7 @@ let ModalsModule = class ModalsModule {
|
|
|
15
12
|
}
|
|
16
13
|
onModuleInit() {
|
|
17
14
|
return this.explorerService
|
|
18
|
-
.explore(
|
|
15
|
+
.explore(Modal.KEY)
|
|
19
16
|
.forEach(modal => this.modalsService.add(modal));
|
|
20
17
|
}
|
|
21
18
|
onApplicationBootstrap() {
|
|
@@ -26,14 +23,14 @@ let ModalsModule = class ModalsModule {
|
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports: [modals_service_1.ModalsService]
|
|
26
|
+
ModalsModule = __decorate([
|
|
27
|
+
Global(),
|
|
28
|
+
Module({
|
|
29
|
+
providers: [ModalsService],
|
|
30
|
+
exports: [ModalsService]
|
|
35
31
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
__metadata("design:paramtypes", [Client,
|
|
33
|
+
NecordExplorerService,
|
|
34
|
+
ModalsService])
|
|
39
35
|
], ModalsModule);
|
|
36
|
+
export { ModalsModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import { ModalDiscovery } from './modal.discovery';
|
|
2
|
+
import { ModalDiscovery } from './modal.discovery.js';
|
|
3
3
|
/**
|
|
4
4
|
* Service that manages modals.
|
|
5
5
|
*/
|
|
@@ -7,6 +7,6 @@ export declare class ModalsService {
|
|
|
7
7
|
private readonly logger;
|
|
8
8
|
readonly cache: Collection<string, ModalDiscovery>;
|
|
9
9
|
add(modal: ModalDiscovery): void;
|
|
10
|
-
get(customId: string): ModalDiscovery;
|
|
10
|
+
get(customId: string): ModalDiscovery | undefined;
|
|
11
11
|
remove(customId: string): void;
|
|
12
12
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var ModalsService_1;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const discord_js_1 = require("discord.js");
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
4
|
+
import { Collection } from 'discord.js';
|
|
8
5
|
/**
|
|
9
6
|
* Service that manages modals.
|
|
10
7
|
*/
|
|
11
8
|
let ModalsService = ModalsService_1 = class ModalsService {
|
|
12
9
|
constructor() {
|
|
13
|
-
this.logger = new
|
|
14
|
-
this.cache = new
|
|
10
|
+
this.logger = new Logger(ModalsService_1.name);
|
|
11
|
+
this.cache = new Collection();
|
|
15
12
|
}
|
|
16
13
|
add(modal) {
|
|
17
14
|
const id = modal.getCustomId();
|
|
@@ -31,7 +28,7 @@ let ModalsService = ModalsService_1 = class ModalsService {
|
|
|
31
28
|
this.cache.delete(customId);
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(0, common_1.Injectable)()
|
|
31
|
+
ModalsService = ModalsService_1 = __decorate([
|
|
32
|
+
Injectable()
|
|
37
33
|
], ModalsService);
|
|
34
|
+
export { ModalsService };
|
|
@@ -4,6 +4,6 @@ export declare class NecordContextCreator {
|
|
|
4
4
|
private readonly externalContextCreator;
|
|
5
5
|
private readonly necordParamsFactory;
|
|
6
6
|
constructor(externalContextCreator: ExternalContextCreator);
|
|
7
|
-
bind(wrapper: InstanceWrapper, methodName: string): (...args: any[]) => Promise<any
|
|
7
|
+
bind(wrapper: InstanceWrapper, methodName: string): ((...args: any[]) => Promise<any>) | undefined;
|
|
8
8
|
private createContextCallback;
|
|
9
9
|
}
|
|
@@ -1,52 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const constants_1 = require("@nestjs/common/constants");
|
|
10
|
-
const constants_2 = require("@nestjs/core/injector/constants");
|
|
11
|
-
const scopes_1 = require("./scopes");
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
|
|
3
|
+
import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
|
|
4
|
+
import { ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
|
|
5
|
+
import { ModuleRef } from '@nestjs/core';
|
|
6
|
+
import { Injectable } from '@nestjs/common';
|
|
7
|
+
import { NecordParamsFactory, NecordParamType } from './context/index.js';
|
|
8
|
+
import { AsyncContext } from './scopes/index.js';
|
|
12
9
|
let NecordContextCreator = class NecordContextCreator {
|
|
13
10
|
constructor(externalContextCreator) {
|
|
14
11
|
this.externalContextCreator = externalContextCreator;
|
|
15
|
-
this.necordParamsFactory = new
|
|
12
|
+
this.necordParamsFactory = new NecordParamsFactory();
|
|
16
13
|
}
|
|
17
14
|
bind(wrapper, methodName) {
|
|
18
15
|
const instance = wrapper.instance;
|
|
19
16
|
if (wrapper.isDependencyTreeStatic() && !wrapper.isTransient) {
|
|
20
17
|
return this.createContextCallback(instance, methodName);
|
|
21
18
|
}
|
|
22
|
-
const
|
|
19
|
+
const host = wrapper.host;
|
|
20
|
+
if (!host) {
|
|
21
|
+
throw new Error('A request-scoped provider must have a Nest module host.');
|
|
22
|
+
}
|
|
23
|
+
const { instance: moduleRef } = host.getProviderByKey(ModuleRef);
|
|
23
24
|
return async (...args) => {
|
|
24
|
-
const necordContext = this.necordParamsFactory.exchangeKeyForValue(
|
|
25
|
-
const context =
|
|
26
|
-
if (!
|
|
25
|
+
const necordContext = this.necordParamsFactory.exchangeKeyForValue(NecordParamType.CONTEXT, undefined, args);
|
|
26
|
+
const context = AsyncContext.of(necordContext) ?? new AsyncContext();
|
|
27
|
+
if (!AsyncContext.isAttached(necordContext)) {
|
|
27
28
|
moduleRef.registerRequestByContextId(necordContext, context.id);
|
|
28
29
|
context.attachTo(necordContext);
|
|
29
30
|
}
|
|
31
|
+
if (!wrapper.metatype) {
|
|
32
|
+
throw new Error('A request-scoped provider must have a metatype.');
|
|
33
|
+
}
|
|
30
34
|
const requestScopedInstance = await moduleRef.resolve(wrapper.metatype, context.id, {
|
|
31
35
|
strict: true
|
|
32
36
|
});
|
|
33
37
|
const contextCallback = this.createContextCallback(requestScopedInstance, methodName, context.id, wrapper.id);
|
|
34
|
-
return contextCallback(...args);
|
|
38
|
+
return contextCallback?.(...args);
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
|
-
createContextCallback(instance, methodName, contextId =
|
|
41
|
+
createContextCallback(instance, methodName, contextId = STATIC_CONTEXT, wrapperId) {
|
|
38
42
|
if (!instance || typeof instance[methodName] !== 'function') {
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
41
45
|
const prototype = Object.getPrototypeOf(instance);
|
|
42
|
-
|
|
46
|
+
const handler = prototype?.[methodName];
|
|
47
|
+
if (typeof handler !== 'function') {
|
|
43
48
|
return;
|
|
44
49
|
}
|
|
45
|
-
return this.externalContextCreator.create(instance,
|
|
50
|
+
return this.externalContextCreator.create(instance, handler, methodName, ROUTE_ARGS_METADATA, this.necordParamsFactory, contextId, wrapperId, { guards: true, filters: true, interceptors: true }, 'necord');
|
|
46
51
|
}
|
|
47
52
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
tslib_1.__metadata("design:paramtypes", [external_context_creator_1.ExternalContextCreator])
|
|
53
|
+
NecordContextCreator = __decorate([
|
|
54
|
+
Injectable(),
|
|
55
|
+
__metadata("design:paramtypes", [ExternalContextCreator])
|
|
52
56
|
], NecordContextCreator);
|
|
57
|
+
export { NecordContextCreator };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NecordBaseDiscovery } from './context';
|
|
2
1
|
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
3
|
-
import { NecordContextCreator } from './necord-context.creator';
|
|
2
|
+
import { NecordContextCreator } from './necord-context.creator.js';
|
|
3
|
+
import { NecordBaseDiscovery } from './context/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a explorer service.
|
|
6
6
|
* This service is used to explore the application and retrieve the discovery items.
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const core_1 = require("@nestjs/core");
|
|
7
|
-
const necord_context_creator_1 = require("./necord-context.creator");
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
3
|
+
import { Injectable } from '@nestjs/common';
|
|
4
|
+
import { NecordContextCreator } from './necord-context.creator.js';
|
|
8
5
|
/**
|
|
9
6
|
* Represents a explorer service.
|
|
10
7
|
* This service is used to explore the application and retrieve the discovery items.
|
|
@@ -25,26 +22,36 @@ let NecordExplorerService = class NecordExplorerService {
|
|
|
25
22
|
return this.flatMap(wrapper => this.filterProperties(wrapper, metadataKey));
|
|
26
23
|
}
|
|
27
24
|
flatMap(callback) {
|
|
28
|
-
return this.wrappers.flatMap(callback).filter(Boolean);
|
|
25
|
+
return this.wrappers.flatMap(callback).filter((item) => Boolean(item));
|
|
29
26
|
}
|
|
30
27
|
filterProperties(wrapper, metadataKey) {
|
|
31
28
|
const { instance } = wrapper;
|
|
29
|
+
if (!instance) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
32
|
const prototype = Object.getPrototypeOf(instance);
|
|
33
|
-
return this.metadataScanner.getAllMethodNames(prototype).
|
|
34
|
-
const
|
|
33
|
+
return this.metadataScanner.getAllMethodNames(prototype).flatMap(methodName => {
|
|
34
|
+
const handler = instance[methodName];
|
|
35
|
+
if (typeof handler !== 'function') {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const item = this.reflector.get(metadataKey, handler);
|
|
35
39
|
if (!item)
|
|
36
|
-
return;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
return [];
|
|
41
|
+
const contextCallback = this.necordContextCreator.bind(wrapper, methodName);
|
|
42
|
+
if (!contextCallback)
|
|
43
|
+
return [];
|
|
44
|
+
item.setDiscoveryMeta({ class: instance.constructor, handler });
|
|
45
|
+
item.setContextCallback(contextCallback);
|
|
46
|
+
return [item];
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
necord_context_creator_1.NecordContextCreator])
|
|
50
|
+
NecordExplorerService = __decorate([
|
|
51
|
+
Injectable(),
|
|
52
|
+
__metadata("design:paramtypes", [Reflector,
|
|
53
|
+
DiscoveryService,
|
|
54
|
+
MetadataScanner,
|
|
55
|
+
NecordContextCreator])
|
|
50
56
|
], NecordExplorerService);
|
|
57
|
+
export { NecordExplorerService };
|
|
@@ -12,6 +12,10 @@ export interface NecordModuleOptions extends DiscordClientOptions {
|
|
|
12
12
|
* If you are using TextCommand, you can specify the prefix here. It can be a string for a static prefix, or a function which returns a string based off the message being sent. If using a function, it can be asynchronous.
|
|
13
13
|
*/
|
|
14
14
|
prefix?: string | Function;
|
|
15
|
+
/**
|
|
16
|
+
* Allows text commands to be used without a prefix when enabled.
|
|
17
|
+
*/
|
|
18
|
+
allowTextCommandsWithoutPrefix?: boolean;
|
|
15
19
|
/**
|
|
16
20
|
* As discord caches application commands for up to an hour, it is recommended to specify a development guild when doing development.
|
|
17
21
|
*
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NecordModuleOptions } from './necord-options.interface';
|
|
1
|
+
import { NecordModuleOptions } from './necord-options.interface.js';
|
|
2
2
|
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<NecordModuleOptions, "forRoot", "createNecordOptions", {}>, NECORD_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: NecordModuleOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<NecordModuleOptions, "createNecordOptions"> & Partial<{}>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ASYNC_OPTIONS_TYPE = exports.OPTIONS_TYPE = exports.NECORD_MODULE_OPTIONS = exports.ConfigurableModuleClass = void 0;
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
_a = new common_1.ConfigurableModuleBuilder()
|
|
1
|
+
import { ConfigurableModuleBuilder } from '@nestjs/common';
|
|
2
|
+
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN: NECORD_MODULE_OPTIONS, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder()
|
|
7
3
|
.setClassMethodName('forRoot')
|
|
8
4
|
.setFactoryMethodName('createNecordOptions')
|
|
9
|
-
.build()
|
|
5
|
+
.build();
|
package/dist/necord.module.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Client } from 'discord.js';
|
|
2
1
|
import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
3
|
-
import {
|
|
4
|
-
import { ConfigurableModuleClass } from './necord.module-definition';
|
|
2
|
+
import { Client } from 'discord.js';
|
|
3
|
+
import { ConfigurableModuleClass } from './necord.module-definition.js';
|
|
4
|
+
import { NecordModuleOptions } from './necord-options.interface.js';
|
|
5
5
|
export declare class NecordModule extends ConfigurableModuleClass implements OnApplicationBootstrap, OnApplicationShutdown {
|
|
6
6
|
private readonly client;
|
|
7
7
|
private readonly options;
|
|
8
8
|
constructor(client: Client, options: NecordModuleOptions);
|
|
9
9
|
onApplicationBootstrap(): Promise<string>;
|
|
10
|
-
onApplicationShutdown(
|
|
10
|
+
onApplicationShutdown(_signal?: string): Promise<void>;
|
|
11
11
|
}
|
package/dist/necord.module.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const commands_1 = require("./commands");
|
|
15
|
-
const core_1 = require("@nestjs/core");
|
|
16
|
-
const necord_context_creator_1 = require("./necord-context.creator");
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { Global, Inject, Module } from '@nestjs/common';
|
|
3
|
+
import { DiscoveryModule } from '@nestjs/core';
|
|
4
|
+
import { Client } from 'discord.js';
|
|
5
|
+
import { ConfigurableModuleClass, NECORD_MODULE_OPTIONS } from './necord.module-definition.js';
|
|
6
|
+
import { MessageComponentsModule } from './message-components/index.js';
|
|
7
|
+
import { NecordExplorerService } from './necord-explorer.service.js';
|
|
8
|
+
import { NecordContextCreator } from './necord-context.creator.js';
|
|
9
|
+
import { TextCommandsModule } from './text-commands/index.js';
|
|
10
|
+
import { ListenersModule } from './listeners/index.js';
|
|
11
|
+
import * as ProvidersMap from './providers/index.js';
|
|
12
|
+
import { CommandsModule } from './commands/index.js';
|
|
13
|
+
import { ModalsModule } from './modals/index.js';
|
|
17
14
|
const Providers = Object.values(ProvidersMap);
|
|
18
|
-
let NecordModule = class NecordModule extends
|
|
15
|
+
let NecordModule = class NecordModule extends ConfigurableModuleClass {
|
|
19
16
|
constructor(client, options) {
|
|
20
17
|
super();
|
|
21
18
|
this.client = client;
|
|
@@ -24,34 +21,34 @@ let NecordModule = class NecordModule extends necord_module_definition_1.Configu
|
|
|
24
21
|
onApplicationBootstrap() {
|
|
25
22
|
return this.client.login(this.options.token);
|
|
26
23
|
}
|
|
27
|
-
onApplicationShutdown(
|
|
24
|
+
onApplicationShutdown(_signal) {
|
|
28
25
|
return this.client.destroy();
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
(0, common_1.Module)({
|
|
28
|
+
NecordModule = __decorate([
|
|
29
|
+
Global(),
|
|
30
|
+
Module({
|
|
35
31
|
imports: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
DiscoveryModule,
|
|
33
|
+
CommandsModule,
|
|
34
|
+
ListenersModule,
|
|
35
|
+
MessageComponentsModule,
|
|
36
|
+
ModalsModule,
|
|
37
|
+
TextCommandsModule
|
|
42
38
|
],
|
|
43
|
-
providers: [
|
|
39
|
+
providers: [NecordExplorerService, NecordContextCreator, ...Providers],
|
|
44
40
|
exports: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
CommandsModule,
|
|
42
|
+
ListenersModule,
|
|
43
|
+
MessageComponentsModule,
|
|
44
|
+
ModalsModule,
|
|
45
|
+
TextCommandsModule,
|
|
46
|
+
NecordExplorerService,
|
|
51
47
|
...Providers,
|
|
52
|
-
|
|
48
|
+
NECORD_MODULE_OPTIONS
|
|
53
49
|
]
|
|
54
50
|
}),
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
__param(1, Inject(NECORD_MODULE_OPTIONS)),
|
|
52
|
+
__metadata("design:paramtypes", [Client, Object])
|
|
57
53
|
], NecordModule);
|
|
54
|
+
export { NecordModule };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.ChannelsProvider = {
|
|
6
|
-
provide: discord_js_1.ChannelManager,
|
|
1
|
+
import { ChannelManager, Client } from 'discord.js';
|
|
2
|
+
export const ChannelsProvider = {
|
|
3
|
+
provide: ChannelManager,
|
|
7
4
|
useFactory: (client) => client.channels,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
provide: discord_js_1.Client,
|
|
8
|
-
useFactory: (options) => new discord_js_1.Client(options),
|
|
9
|
-
inject: [necord_module_definition_1.NECORD_MODULE_OPTIONS]
|
|
1
|
+
import { Client } from 'discord.js';
|
|
2
|
+
import { NECORD_MODULE_OPTIONS } from '../necord.module-definition.js';
|
|
3
|
+
export const ClientProvider = {
|
|
4
|
+
provide: Client,
|
|
5
|
+
useFactory: (options) => new Client(options),
|
|
6
|
+
inject: [NECORD_MODULE_OPTIONS]
|
|
10
7
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.GuildsProvider = {
|
|
6
|
-
provide: discord_js_1.GuildManager,
|
|
1
|
+
import { Client, GuildManager } from 'discord.js';
|
|
2
|
+
export const GuildsProvider = {
|
|
3
|
+
provide: GuildManager,
|
|
7
4
|
useFactory: (client) => client.guilds,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './channels.provider';
|
|
2
|
-
export * from './client.provider';
|
|
3
|
-
export * from './guilds.provider';
|
|
4
|
-
export * from './rest.provider';
|
|
5
|
-
export * from './shard.provider';
|
|
6
|
-
export * from './users.provider';
|
|
7
|
-
export * from './voice.provider';
|
|
8
|
-
export * from './ws.provider';
|
|
1
|
+
export * from './channels.provider.js';
|
|
2
|
+
export * from './client.provider.js';
|
|
3
|
+
export * from './guilds.provider.js';
|
|
4
|
+
export * from './rest.provider.js';
|
|
5
|
+
export * from './shard.provider.js';
|
|
6
|
+
export * from './users.provider.js';
|
|
7
|
+
export * from './voice.provider.js';
|
|
8
|
+
export * from './ws.provider.js';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tslib_1.__exportStar(require("./users.provider"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./voice.provider"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./ws.provider"), exports);
|
|
1
|
+
export * from './channels.provider.js';
|
|
2
|
+
export * from './client.provider.js';
|
|
3
|
+
export * from './guilds.provider.js';
|
|
4
|
+
export * from './rest.provider.js';
|
|
5
|
+
export * from './shard.provider.js';
|
|
6
|
+
export * from './users.provider.js';
|
|
7
|
+
export * from './voice.provider.js';
|
|
8
|
+
export * from './ws.provider.js';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.RestProvider = {
|
|
6
|
-
provide: discord_js_1.REST,
|
|
1
|
+
import { Client, REST } from 'discord.js';
|
|
2
|
+
export const RestProvider = {
|
|
3
|
+
provide: REST,
|
|
7
4
|
useFactory: (client) => client.rest,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Provider } from '@nestjs/common';
|
|
2
1
|
import { ShardClientUtil } from 'discord.js';
|
|
3
|
-
|
|
2
|
+
import { Provider } from '@nestjs/common';
|
|
3
|
+
export declare const ShardProvider: Provider<null | ShardClientUtil>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.ShardProvider = {
|
|
6
|
-
provide: discord_js_1.ShardClientUtil,
|
|
1
|
+
import { Client, ShardClientUtil } from 'discord.js';
|
|
2
|
+
export const ShardProvider = {
|
|
3
|
+
provide: ShardClientUtil,
|
|
7
4
|
useFactory: (client) => client.shard,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|