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
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const CustomListeners = tslib_1.__importStar(require("./handlers"));
|
|
11
|
-
const scopes_1 = require("./scopes");
|
|
12
|
-
const { BaseHandler, ...listeners } = CustomListeners;
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { DiscoveryModule, DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
3
|
+
import { Global, Module } from '@nestjs/common';
|
|
4
|
+
import { Client } from 'discord.js';
|
|
5
|
+
import { AsyncCustomListenerContext } from './scopes/index.js';
|
|
6
|
+
import { CustomListener, CustomListenerHandler, Listener } from './decorators/index.js';
|
|
7
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
8
|
+
import * as CustomListeners from './handlers/index.js';
|
|
9
|
+
const { BaseHandler: _, ...LISTENERS } = CustomListeners;
|
|
13
10
|
let ListenersModule = class ListenersModule {
|
|
14
11
|
constructor(client, explorerService, discoveryService, metadataScanner, reflector) {
|
|
15
12
|
this.client = client;
|
|
@@ -20,42 +17,45 @@ let ListenersModule = class ListenersModule {
|
|
|
20
17
|
}
|
|
21
18
|
onModuleInit() {
|
|
22
19
|
return this.explorerService
|
|
23
|
-
.explore(
|
|
20
|
+
.explore(Listener.KEY)
|
|
24
21
|
.forEach(listener => this.client[listener.getType()](listener.getEvent(), (...args) => listener.execute(args)));
|
|
25
22
|
}
|
|
26
23
|
onApplicationBootstrap() {
|
|
27
24
|
const wrappers = this.discoveryService.getProviders({
|
|
28
|
-
metadataKey:
|
|
25
|
+
metadataKey: CustomListener.KEY
|
|
29
26
|
});
|
|
30
27
|
for (const wrapper of wrappers) {
|
|
31
|
-
const customListener = this.discoveryService.getMetadataByDecorator(
|
|
28
|
+
const customListener = this.discoveryService.getMetadataByDecorator(CustomListener, wrapper);
|
|
32
29
|
const instance = wrapper.instance;
|
|
30
|
+
if (!customListener || !instance) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
33
|
const prototype = Object.getPrototypeOf(instance);
|
|
34
34
|
const methods = this.metadataScanner
|
|
35
35
|
.getAllMethodNames(prototype)
|
|
36
|
-
.filter(method => this.reflector.get(
|
|
36
|
+
.filter(method => this.reflector.get(CustomListenerHandler, prototype[method]));
|
|
37
37
|
this.client.on(customListener, (...args) => {
|
|
38
38
|
const context = {
|
|
39
39
|
root: customListener,
|
|
40
40
|
args: args
|
|
41
41
|
};
|
|
42
42
|
for (const method of methods) {
|
|
43
|
-
|
|
43
|
+
AsyncCustomListenerContext.runInContext(context, instance[method].bind(instance, args));
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
providers: Object.values(listeners)
|
|
49
|
+
ListenersModule = __decorate([
|
|
50
|
+
Global(),
|
|
51
|
+
Module({
|
|
52
|
+
imports: [DiscoveryModule],
|
|
53
|
+
providers: Object.values(LISTENERS)
|
|
55
54
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
__metadata("design:paramtypes", [Client,
|
|
56
|
+
NecordExplorerService,
|
|
57
|
+
DiscoveryService,
|
|
58
|
+
MetadataScanner,
|
|
59
|
+
Reflector])
|
|
61
60
|
], ListenersModule);
|
|
61
|
+
export { ListenersModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ClientEvents } from 'discord.js';
|
|
2
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { ClientEvents } from 'discord.js';
|
|
3
3
|
declare const ASYNC_CUSTOM_LISTENER_STORAGE: unique symbol;
|
|
4
4
|
export interface AsyncCustomListenerContextOptions {
|
|
5
5
|
root: keyof ClientEvents;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const node_async_hooks_1 = require("node:async_hooks");
|
|
6
|
-
const core_1 = require("@nestjs/core");
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
import { ContextIdFactory } from '@nestjs/core';
|
|
7
4
|
const ASYNC_CUSTOM_LISTENER_STORAGE = Symbol('ASYNC_CUSTOM_LISTENER_STORAGE');
|
|
8
|
-
class AsyncCustomListenerContext {
|
|
5
|
+
export class AsyncCustomListenerContext {
|
|
6
|
+
static { _a = ASYNC_CUSTOM_LISTENER_STORAGE; }
|
|
7
|
+
static { this[_a] = new AsyncLocalStorage(); }
|
|
9
8
|
constructor(root, args) {
|
|
10
9
|
this.root = root;
|
|
11
10
|
this.args = args;
|
|
12
|
-
this.id =
|
|
11
|
+
this.id = ContextIdFactory.create();
|
|
13
12
|
}
|
|
14
13
|
static isAttached() {
|
|
15
14
|
return Boolean(AsyncCustomListenerContext[ASYNC_CUSTOM_LISTENER_STORAGE].getStore());
|
|
@@ -32,6 +31,3 @@ class AsyncCustomListenerContext {
|
|
|
32
31
|
return this.args;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
exports.AsyncCustomListenerContext = AsyncCustomListenerContext;
|
|
36
|
-
_a = ASYNC_CUSTOM_LISTENER_STORAGE;
|
|
37
|
-
AsyncCustomListenerContext[_a] = new node_async_hooks_1.AsyncLocalStorage();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './async-custom-listener.context';
|
|
1
|
+
export * from './async-custom-listener.context.js';
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Button = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const message_component_decorator_1 = require("./message-component.decorator");
|
|
1
|
+
import { ComponentType } from 'discord.js';
|
|
2
|
+
import { MessageComponent } from './message-component.decorator.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a button for discord.js client.
|
|
8
5
|
* @param customId
|
|
9
6
|
* @url https://necord.org/interactions/message-components#button
|
|
10
7
|
*/
|
|
11
|
-
const Button = (customId) =>
|
|
12
|
-
exports.Button = Button;
|
|
8
|
+
export const Button = (customId) => MessageComponent({ customId, type: ComponentType.Button });
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ComponentParam = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const context_1 = require("../../context");
|
|
1
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { NecordExecutionContext } from '../../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Represents a component param decorator.
|
|
8
5
|
* @url https://necord.org/interactions/message-components#dynamic-button
|
|
@@ -10,8 +7,8 @@ const context_1 = require("../../context");
|
|
|
10
7
|
* @returns The component param decorator.
|
|
11
8
|
* @url https://necord.org/interactions/message-components#dynamic-select-menu
|
|
12
9
|
*/
|
|
13
|
-
|
|
14
|
-
const necordContext =
|
|
10
|
+
export const ComponentParam = createParamDecorator((data, ctx) => {
|
|
11
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
15
12
|
const [interaction] = necordContext.getContext();
|
|
16
13
|
const discovery = necordContext.getDiscovery();
|
|
17
14
|
if (!discovery.isMessageComponent() || !interaction.isMessageComponent())
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './button.decorator';
|
|
2
|
-
export * from './component-param.decorator';
|
|
3
|
-
export * from './message-component.decorator';
|
|
4
|
-
export * from './select-menu.decorator';
|
|
5
|
-
export * from './selected.decorator';
|
|
1
|
+
export * from './button.decorator.js';
|
|
2
|
+
export * from './component-param.decorator.js';
|
|
3
|
+
export * from './message-component.decorator.js';
|
|
4
|
+
export * from './select-menu.decorator.js';
|
|
5
|
+
export * from './selected.decorator.js';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tslib_1.__exportStar(require("./message-component.decorator"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./select-menu.decorator"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./selected.decorator"), exports);
|
|
1
|
+
export * from './button.decorator.js';
|
|
2
|
+
export * from './component-param.decorator.js';
|
|
3
|
+
export * from './message-component.decorator.js';
|
|
4
|
+
export * from './select-menu.decorator.js';
|
|
5
|
+
export * from './selected.decorator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageComponentDiscovery, MessageComponentMeta } from '../message-component.discovery';
|
|
1
|
+
import { MessageComponentDiscovery, MessageComponentMeta } from '../message-component.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a message component for discord.js client.
|
|
4
4
|
* @param options The message component options.
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MessageComponent = void 0;
|
|
4
|
-
const message_component_discovery_1 = require("../message-component.discovery");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
1
|
+
import { Reflector } from '@nestjs/core';
|
|
2
|
+
import { MessageComponentDiscovery } from '../message-component.discovery.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a message component for discord.js client.
|
|
8
5
|
* @param options The message component options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/message-components
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
transform: options => new
|
|
9
|
+
export const MessageComponent = Reflector.createDecorator({
|
|
10
|
+
transform: options => new MessageComponentDiscovery(options)
|
|
14
11
|
});
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RoleSelect = exports.MentionableSelect = exports.UserSelect = exports.ChannelSelect = exports.StringSelect = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const message_component_decorator_1 = require("./message-component.decorator");
|
|
1
|
+
import { ComponentType } from 'discord.js';
|
|
2
|
+
import { MessageComponent } from './message-component.decorator.js';
|
|
6
3
|
/**
|
|
7
4
|
* Select Menu for picking defined text options
|
|
8
5
|
* @param customId
|
|
9
6
|
* @see SelectedStrings
|
|
10
7
|
* @url https://necord.org/interactions/message-components#string-select
|
|
11
8
|
*/
|
|
12
|
-
const StringSelect = (customId) =>
|
|
13
|
-
exports.StringSelect = StringSelect;
|
|
9
|
+
export const StringSelect = (customId) => MessageComponent({ customId, type: ComponentType.StringSelect });
|
|
14
10
|
/**
|
|
15
11
|
* Select Menu for selecting channels
|
|
16
12
|
* @param customId
|
|
17
13
|
* @see SelectedChannels
|
|
18
14
|
* @url https://necord.org/interactions/message-components#channel-select
|
|
19
15
|
*/
|
|
20
|
-
const ChannelSelect = (customId) =>
|
|
21
|
-
exports.ChannelSelect = ChannelSelect;
|
|
16
|
+
export const ChannelSelect = (customId) => MessageComponent({ customId, type: ComponentType.ChannelSelect });
|
|
22
17
|
/**
|
|
23
18
|
* Select Menu for selecting users
|
|
24
19
|
* @param customId
|
|
@@ -26,8 +21,7 @@ exports.ChannelSelect = ChannelSelect;
|
|
|
26
21
|
* @see SelectedMembers
|
|
27
22
|
* @url https://necord.org/interactions/message-components#user-select
|
|
28
23
|
*/
|
|
29
|
-
const UserSelect = (customId) =>
|
|
30
|
-
exports.UserSelect = UserSelect;
|
|
24
|
+
export const UserSelect = (customId) => MessageComponent({ customId, type: ComponentType.UserSelect });
|
|
31
25
|
/**
|
|
32
26
|
* Select Menu for selecting members
|
|
33
27
|
* @param customId
|
|
@@ -36,13 +30,11 @@ exports.UserSelect = UserSelect;
|
|
|
36
30
|
* @see SelectedMembers
|
|
37
31
|
* @see SelectedRoles
|
|
38
32
|
*/
|
|
39
|
-
const MentionableSelect = (customId) =>
|
|
40
|
-
exports.MentionableSelect = MentionableSelect;
|
|
33
|
+
export const MentionableSelect = (customId) => MessageComponent({ customId, type: ComponentType.MentionableSelect });
|
|
41
34
|
/**
|
|
42
35
|
* Select Menu for selecting roles
|
|
43
36
|
* @param customId
|
|
44
37
|
* @see SelectedRoles
|
|
45
38
|
* @url https://necord.org/interactions/message-components#role-select
|
|
46
39
|
*/
|
|
47
|
-
const RoleSelect = (customId) =>
|
|
48
|
-
exports.RoleSelect = RoleSelect;
|
|
40
|
+
export const RoleSelect = (customId) => MessageComponent({ customId, type: ComponentType.RoleSelect });
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const context_1 = require("../../context");
|
|
7
|
-
exports.SelectedStrings = (0, common_1.createParamDecorator)((_, ctx) => {
|
|
8
|
-
const necordContext = context_1.NecordExecutionContext.create(ctx);
|
|
1
|
+
import { Collection } from 'discord.js';
|
|
2
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
3
|
+
import { NecordExecutionContext } from '../../context/index.js';
|
|
4
|
+
export const SelectedStrings = createParamDecorator((_, ctx) => {
|
|
5
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
9
6
|
const [interaction] = necordContext.getContext();
|
|
10
7
|
return interaction.isStringSelectMenu() ? interaction.values : [];
|
|
11
8
|
});
|
|
12
|
-
|
|
13
|
-
const necordContext =
|
|
9
|
+
export const SelectedChannels = createParamDecorator((_, ctx) => {
|
|
10
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
14
11
|
const [interaction] = necordContext.getContext();
|
|
15
|
-
return interaction.isChannelSelectMenu() ? interaction.channels : new
|
|
12
|
+
return interaction.isChannelSelectMenu() ? interaction.channels : new Collection();
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
const necordContext =
|
|
14
|
+
export const SelectedUsers = createParamDecorator((_, ctx) => {
|
|
15
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
19
16
|
const [interaction] = necordContext.getContext();
|
|
20
17
|
if (interaction.isUserSelectMenu() || interaction.isMentionableSelectMenu()) {
|
|
21
18
|
return interaction.users;
|
|
22
19
|
}
|
|
23
|
-
return new
|
|
20
|
+
return new Collection();
|
|
24
21
|
});
|
|
25
|
-
|
|
26
|
-
const necordContext =
|
|
22
|
+
export const SelectedMembers = createParamDecorator((_, ctx) => {
|
|
23
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
27
24
|
const [interaction] = necordContext.getContext();
|
|
28
25
|
if (interaction.isUserSelectMenu() || interaction.isMentionableSelectMenu()) {
|
|
29
26
|
return interaction.members;
|
|
30
27
|
}
|
|
31
|
-
return new
|
|
28
|
+
return new Collection();
|
|
32
29
|
});
|
|
33
|
-
|
|
34
|
-
const necordContext =
|
|
30
|
+
export const SelectedRoles = createParamDecorator((_, ctx) => {
|
|
31
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
35
32
|
const [interaction] = necordContext.getContext();
|
|
36
33
|
if (interaction.isRoleSelectMenu() || interaction.isMentionableSelectMenu()) {
|
|
37
34
|
return interaction.roles;
|
|
38
35
|
}
|
|
39
|
-
return new
|
|
36
|
+
return new Collection();
|
|
40
37
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './decorators';
|
|
2
|
-
export * from './message-component.discovery';
|
|
3
|
-
export * from './message-components.module';
|
|
4
|
-
export * from './message-components.service';
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './message-component.discovery.js';
|
|
3
|
+
export * from './message-components.module.js';
|
|
4
|
+
export * from './message-components.service.js';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./message-component.discovery"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./message-components.module"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./message-components.service"), exports);
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './message-component.discovery.js';
|
|
3
|
+
export * from './message-components.module.js';
|
|
4
|
+
export * from './message-components.service.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, MessageComponentInteraction, MessageComponentType } from 'discord.js';
|
|
2
|
-
import { NecordBaseDiscovery } from '../context';
|
|
2
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
3
3
|
export interface MessageComponentMeta {
|
|
4
4
|
type: Exclude<MessageComponentType, ComponentType.ActionRow | ComponentType.TextInput>;
|
|
5
5
|
customId: string;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MessageComponentDiscovery = void 0;
|
|
4
|
-
const path_to_regexp_1 = require("path-to-regexp");
|
|
5
|
-
const context_1 = require("../context");
|
|
1
|
+
import { match } from 'path-to-regexp';
|
|
2
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Represents a message component discovery.
|
|
8
5
|
*/
|
|
9
|
-
class MessageComponentDiscovery extends
|
|
6
|
+
export class MessageComponentDiscovery extends NecordBaseDiscovery {
|
|
10
7
|
constructor() {
|
|
11
8
|
super(...arguments);
|
|
12
|
-
this.matcher =
|
|
9
|
+
this.matcher = match([this.meta.type.toString(), this.meta.customId].join('_'));
|
|
13
10
|
}
|
|
14
11
|
getType() {
|
|
15
12
|
return this.meta.type;
|
|
@@ -27,4 +24,3 @@ class MessageComponentDiscovery extends context_1.NecordBaseDiscovery {
|
|
|
27
24
|
return this.meta;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.MessageComponentDiscovery = MessageComponentDiscovery;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { MessageComponentsService } from './message-components.service';
|
|
3
2
|
import { Client } from 'discord.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import { MessageComponentDiscovery } from './message-component.discovery.js';
|
|
4
|
+
import { MessageComponentsService } from './message-components.service.js';
|
|
5
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
6
|
+
export declare class MessageComponentsModule implements OnApplicationBootstrap, OnModuleInit {
|
|
7
7
|
private readonly client;
|
|
8
8
|
private readonly explorerService;
|
|
9
9
|
private readonly messageComponentsService;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const discord_js_1 = require("discord.js");
|
|
8
|
-
const necord_explorer_service_1 = require("../necord-explorer.service");
|
|
9
|
-
const decorators_1 = require("./decorators");
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Global, Module } from '@nestjs/common';
|
|
3
|
+
import { Client } from 'discord.js';
|
|
4
|
+
import { MessageComponentsService } from './message-components.service.js';
|
|
5
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
6
|
+
import { MessageComponent } from './decorators/index.js';
|
|
10
7
|
let MessageComponentsModule = class MessageComponentsModule {
|
|
11
8
|
constructor(client, explorerService, messageComponentsService) {
|
|
12
9
|
this.client = client;
|
|
@@ -15,7 +12,7 @@ let MessageComponentsModule = class MessageComponentsModule {
|
|
|
15
12
|
}
|
|
16
13
|
onModuleInit() {
|
|
17
14
|
return this.explorerService
|
|
18
|
-
.explore(
|
|
15
|
+
.explore(MessageComponent.KEY)
|
|
19
16
|
.forEach(component => this.messageComponentsService.add(component));
|
|
20
17
|
}
|
|
21
18
|
onApplicationBootstrap() {
|
|
@@ -28,14 +25,14 @@ let MessageComponentsModule = class MessageComponentsModule {
|
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports: [message_components_service_1.MessageComponentsService]
|
|
28
|
+
MessageComponentsModule = __decorate([
|
|
29
|
+
Global(),
|
|
30
|
+
Module({
|
|
31
|
+
providers: [MessageComponentsService],
|
|
32
|
+
exports: [MessageComponentsService]
|
|
37
33
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
__metadata("design:paramtypes", [Client,
|
|
35
|
+
NecordExplorerService,
|
|
36
|
+
MessageComponentsService])
|
|
41
37
|
], MessageComponentsModule);
|
|
38
|
+
export { MessageComponentsModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import { MessageComponentDiscovery, MessageComponentMeta } from './message-component.discovery';
|
|
2
|
+
import { MessageComponentDiscovery, MessageComponentMeta } from './message-component.discovery.js';
|
|
3
3
|
/**
|
|
4
4
|
* Service that manages message components.
|
|
5
5
|
*/
|
|
@@ -8,6 +8,6 @@ export declare class MessageComponentsService {
|
|
|
8
8
|
readonly cache: Collection<string, MessageComponentDiscovery>;
|
|
9
9
|
private componentName;
|
|
10
10
|
add(component: MessageComponentDiscovery): void;
|
|
11
|
-
get(type: MessageComponentMeta['type'], customId: MessageComponentMeta['customId']): MessageComponentDiscovery;
|
|
11
|
+
get(type: MessageComponentMeta['type'], customId: MessageComponentMeta['customId']): MessageComponentDiscovery | undefined;
|
|
12
12
|
remove(type: MessageComponentMeta['type'], customId: MessageComponentMeta['customId']): void;
|
|
13
13
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var MessageComponentsService_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 message components.
|
|
10
7
|
*/
|
|
11
8
|
let MessageComponentsService = MessageComponentsService_1 = class MessageComponentsService {
|
|
12
9
|
constructor() {
|
|
13
|
-
this.logger = new
|
|
14
|
-
this.cache = new
|
|
10
|
+
this.logger = new Logger(MessageComponentsService_1.name);
|
|
11
|
+
this.cache = new Collection();
|
|
15
12
|
}
|
|
16
13
|
componentName(type, customId) {
|
|
17
14
|
return [type, customId].join('_');
|
|
@@ -34,7 +31,7 @@ let MessageComponentsService = MessageComponentsService_1 = class MessageCompone
|
|
|
34
31
|
this.cache.delete(this.componentName(type, customId));
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(0, common_1.Injectable)()
|
|
34
|
+
MessageComponentsService = MessageComponentsService_1 = __decorate([
|
|
35
|
+
Injectable()
|
|
40
36
|
], MessageComponentsService);
|
|
37
|
+
export { MessageComponentsService };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Fields = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const context_1 = require("../../context");
|
|
1
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { NecordExecutionContext } from '../../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Represents a fields param decorator.
|
|
8
5
|
* @url https://necord.org/interactions/modals
|
|
9
6
|
* @param customId The custom id.
|
|
10
7
|
* @returns The fields param decorator.
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
const necordContext =
|
|
9
|
+
export const Fields = createParamDecorator((customId, context) => {
|
|
10
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
14
11
|
const [interaction] = necordContext.getContext();
|
|
15
12
|
const discovery = necordContext.getDiscovery();
|
|
16
13
|
if (!interaction.isModalSubmit() || !discovery.isModal()) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './fields.decorator';
|
|
2
|
-
export * from './modal.decorator';
|
|
3
|
-
export * from './modal
|
|
1
|
+
export * from './fields.decorator.js';
|
|
2
|
+
export * from './modal-param.decorator.js';
|
|
3
|
+
export * from './modal.decorator.js';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./fields.decorator"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./modal.decorator"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./modal-param.decorator"), exports);
|
|
1
|
+
export * from './fields.decorator.js';
|
|
2
|
+
export * from './modal-param.decorator.js';
|
|
3
|
+
export * from './modal.decorator.js';
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ModalParam = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const context_1 = require("../../context");
|
|
1
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { NecordExecutionContext } from '../../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Represents a modal param decorator.
|
|
8
5
|
* @url https://necord.org/interactions/modals
|
|
9
6
|
* @returns The modal param decorator.
|
|
10
7
|
* @url https://necord.org/interactions/modals#dynamic-modal
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
const necordContext =
|
|
9
|
+
export const ModalParam = createParamDecorator((data, ctx) => {
|
|
10
|
+
const necordContext = NecordExecutionContext.create(ctx);
|
|
14
11
|
const [interaction] = necordContext.getContext();
|
|
15
12
|
const discovery = necordContext.getDiscovery();
|
|
16
13
|
if (!discovery.isModal() || !interaction.isModalSubmit())
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Modal = void 0;
|
|
4
|
-
const modal_discovery_1 = require("../modal.discovery");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
1
|
+
import { Reflector } from '@nestjs/core';
|
|
2
|
+
import { ModalDiscovery } from '../modal.discovery.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a modal for discord.js client.
|
|
8
5
|
* @param customId The custom id of the modal.
|
|
9
6
|
* @url https://necord.org/interactions/modals
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
transform: customId => new
|
|
8
|
+
export const Modal = Reflector.createDecorator({
|
|
9
|
+
transform: customId => new ModalDiscovery({ customId })
|
|
13
10
|
});
|
package/dist/modals/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './decorators';
|
|
2
|
-
export * from './modal.discovery';
|
|
3
|
-
export * from './modals.module';
|
|
4
|
-
export * from './modals.service';
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './modal.discovery.js';
|
|
3
|
+
export * from './modals.module.js';
|
|
4
|
+
export * from './modals.service.js';
|