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,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.UsersProvider = {
|
|
6
|
-
provide: discord_js_1.UserManager,
|
|
1
|
+
import { Client, UserManager } from 'discord.js';
|
|
2
|
+
export const UsersProvider = {
|
|
3
|
+
provide: UserManager,
|
|
7
4
|
useFactory: (client) => client.users,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.VoiceProvider = {
|
|
6
|
-
provide: discord_js_1.ClientVoiceManager,
|
|
1
|
+
import { Client, ClientVoiceManager } from 'discord.js';
|
|
2
|
+
export const VoiceProvider = {
|
|
3
|
+
provide: ClientVoiceManager,
|
|
7
4
|
useFactory: (client) => client.voice,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
exports.WsProvider = {
|
|
6
|
-
provide: discord_js_1.WebSocketManager,
|
|
1
|
+
import { Client, WebSocketManager } from 'discord.js';
|
|
2
|
+
export const WsProvider = {
|
|
3
|
+
provide: WebSocketManager,
|
|
7
4
|
useFactory: (client) => client.ws,
|
|
8
|
-
inject: [
|
|
5
|
+
inject: [Client]
|
|
9
6
|
};
|
|
@@ -12,7 +12,7 @@ export declare class AsyncContext {
|
|
|
12
12
|
/**
|
|
13
13
|
* Checks if target is already attached to any async context.
|
|
14
14
|
* @param target The object to check.
|
|
15
|
-
* @returns "true" if the target is attached to
|
|
15
|
+
* @returns "true" if the target is attached to any async context.
|
|
16
16
|
*/
|
|
17
17
|
static isAttached(target: object): boolean;
|
|
18
18
|
/**
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AsyncContext = exports.ASYNC_CONTEXT_ATTRIBUTE = void 0;
|
|
4
|
-
const core_1 = require("@nestjs/core");
|
|
5
|
-
exports.ASYNC_CONTEXT_ATTRIBUTE = Symbol('ASYNC_CONTEXT_ATTRIBUTE');
|
|
1
|
+
import { ContextIdFactory } from '@nestjs/core';
|
|
2
|
+
export const ASYNC_CONTEXT_ATTRIBUTE = Symbol('ASYNC_CONTEXT_ATTRIBUTE');
|
|
6
3
|
/**
|
|
7
4
|
* Represents the context of an asynchronous operation.
|
|
8
5
|
*/
|
|
9
|
-
class AsyncContext {
|
|
6
|
+
export class AsyncContext {
|
|
10
7
|
constructor() {
|
|
11
|
-
this.id =
|
|
8
|
+
this.id = ContextIdFactory.create();
|
|
12
9
|
}
|
|
13
10
|
/**
|
|
14
11
|
* Attaches the context to an object.
|
|
15
12
|
* @param target The object to attach the context to.
|
|
16
13
|
*/
|
|
17
14
|
attachTo(target) {
|
|
18
|
-
Object.defineProperty(target,
|
|
15
|
+
Object.defineProperty(target, ASYNC_CONTEXT_ATTRIBUTE, {
|
|
19
16
|
value: this,
|
|
20
17
|
enumerable: false
|
|
21
18
|
});
|
|
@@ -23,10 +20,10 @@ class AsyncContext {
|
|
|
23
20
|
/**
|
|
24
21
|
* Checks if target is already attached to any async context.
|
|
25
22
|
* @param target The object to check.
|
|
26
|
-
* @returns "true" if the target is attached to
|
|
23
|
+
* @returns "true" if the target is attached to any async context.
|
|
27
24
|
*/
|
|
28
25
|
static isAttached(target) {
|
|
29
|
-
return !!target[
|
|
26
|
+
return !!target[ASYNC_CONTEXT_ATTRIBUTE];
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Merges the context of an asynchronous operation from a given command, query, or event to another object.
|
|
@@ -37,11 +34,11 @@ class AsyncContext {
|
|
|
37
34
|
if (!from || !to) {
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
40
|
-
const fromContext = from[
|
|
37
|
+
const fromContext = from[ASYNC_CONTEXT_ATTRIBUTE];
|
|
41
38
|
if (!fromContext) {
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
|
-
Object.defineProperty(to,
|
|
41
|
+
Object.defineProperty(to, ASYNC_CONTEXT_ATTRIBUTE, {
|
|
45
42
|
value: fromContext,
|
|
46
43
|
enumerable: false
|
|
47
44
|
});
|
|
@@ -52,7 +49,6 @@ class AsyncContext {
|
|
|
52
49
|
* @returns An "AsyncContext" instance or "undefined" if the context is not found.
|
|
53
50
|
*/
|
|
54
51
|
static of(target) {
|
|
55
|
-
return target[
|
|
52
|
+
return target[ASYNC_CONTEXT_ATTRIBUTE];
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
|
-
exports.AsyncContext = AsyncContext;
|
package/dist/scopes/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './async.context';
|
|
1
|
+
export * from './async.context.js';
|
package/dist/scopes/index.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Args = exports.Arguments = 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 an arguments param decorator.
|
|
8
5
|
* @url https://necord.org/text-commands
|
|
9
6
|
* @returns The arguments param decorator.
|
|
10
7
|
* @url https://necord.org/text-commands#arguments
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
const necordContext =
|
|
9
|
+
export const Arguments = createParamDecorator((_, context) => {
|
|
10
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
14
11
|
const [message] = necordContext.getContext();
|
|
15
12
|
const discovery = necordContext.getDiscovery();
|
|
16
13
|
if (!discovery.isTextCommand())
|
|
17
14
|
return null;
|
|
18
15
|
return message.content.split(/ +/g).slice(1);
|
|
19
16
|
});
|
|
20
|
-
|
|
17
|
+
export const Args = Arguments;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './arguments.decorator';
|
|
2
|
-
export * from './text-command.decorator';
|
|
1
|
+
export * from './arguments.decorator.js';
|
|
2
|
+
export * from './text-command.decorator.js';
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./arguments.decorator"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./text-command.decorator"), exports);
|
|
1
|
+
export * from './arguments.decorator.js';
|
|
2
|
+
export * from './text-command.decorator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextCommandDiscovery, TextCommandMeta } from '../text-command.discovery';
|
|
1
|
+
import { TextCommandDiscovery, TextCommandMeta } from '../text-command.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a text command for discord.js client.
|
|
4
4
|
* @param options The options for the text command.
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TextCommand = void 0;
|
|
4
|
-
const text_command_discovery_1 = require("../text-command.discovery");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
1
|
+
import { Reflector } from '@nestjs/core';
|
|
2
|
+
import { TextCommandDiscovery } from '../text-command.discovery.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a text command for discord.js client.
|
|
8
5
|
* @param options The options for the text command.
|
|
9
6
|
* @url https://necord.org/text-commands
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
transform: (options) => new
|
|
8
|
+
export const TextCommand = Reflector.createDecorator({
|
|
9
|
+
transform: (options) => new TextCommandDiscovery(options)
|
|
13
10
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './decorators';
|
|
2
|
-
export * from './text-command.discovery';
|
|
3
|
-
export * from './text-commands.module';
|
|
4
|
-
export * from './text-commands.service';
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './text-command.discovery.js';
|
|
3
|
+
export * from './text-commands.module.js';
|
|
4
|
+
export * from './text-commands.service.js';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./text-command.discovery"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./text-commands.module"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./text-commands.service"), exports);
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export * from './text-command.discovery.js';
|
|
3
|
+
export * from './text-commands.module.js';
|
|
4
|
+
export * from './text-commands.service.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { NecordBaseDiscovery } from '../context';
|
|
1
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
2
2
|
export interface TextCommandMeta {
|
|
3
3
|
name: string;
|
|
4
4
|
description: string;
|
|
5
|
+
aliases?: string[];
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Represents a text command discovery.
|
|
@@ -9,6 +10,7 @@ export interface TextCommandMeta {
|
|
|
9
10
|
export declare class TextCommandDiscovery extends NecordBaseDiscovery<TextCommandMeta> {
|
|
10
11
|
getName(): string;
|
|
11
12
|
getDescription(): string;
|
|
13
|
+
getAliases(): string[];
|
|
12
14
|
isTextCommand(): this is TextCommandDiscovery;
|
|
13
15
|
toJSON(): Record<string, any>;
|
|
14
16
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextCommandDiscovery = void 0;
|
|
4
|
-
const context_1 = require("../context");
|
|
1
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Represents a text command discovery.
|
|
7
4
|
*/
|
|
8
|
-
class TextCommandDiscovery extends
|
|
5
|
+
export class TextCommandDiscovery extends NecordBaseDiscovery {
|
|
9
6
|
getName() {
|
|
10
7
|
return this.meta.name;
|
|
11
8
|
}
|
|
12
9
|
getDescription() {
|
|
13
10
|
return this.meta.description;
|
|
14
11
|
}
|
|
12
|
+
getAliases() {
|
|
13
|
+
return this.meta.aliases ?? [];
|
|
14
|
+
}
|
|
15
15
|
isTextCommand() {
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
@@ -19,4 +19,3 @@ class TextCommandDiscovery extends context_1.NecordBaseDiscovery {
|
|
|
19
19
|
return this.meta;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
exports.TextCommandDiscovery = TextCommandDiscovery;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { TextCommandsService } from './text-commands.service';
|
|
3
|
-
import { NecordModuleOptions } from '../necord-options.interface';
|
|
4
2
|
import { Client } from 'discord.js';
|
|
5
|
-
import { NecordExplorerService } from '../necord-explorer.service';
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
4
|
+
import { NecordModuleOptions } from '../necord-options.interface.js';
|
|
5
|
+
import { TextCommandDiscovery } from './text-command.discovery.js';
|
|
6
|
+
import { TextCommandsService } from './text-commands.service.js';
|
|
7
|
+
export declare class TextCommandsModule implements OnApplicationBootstrap, OnModuleInit {
|
|
8
8
|
private readonly options;
|
|
9
9
|
private readonly client;
|
|
10
10
|
private readonly explorerService;
|
|
11
11
|
private readonly textCommandsService;
|
|
12
12
|
constructor(options: NecordModuleOptions, client: Client, explorerService: NecordExplorerService<TextCommandDiscovery>, textCommandsService: TextCommandsService);
|
|
13
|
-
onModuleInit(): void
|
|
13
|
+
onModuleInit(): Promise<void>;
|
|
14
14
|
onApplicationBootstrap(): Client<boolean>;
|
|
15
15
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const necord_module_definition_1 = require("../necord.module-definition");
|
|
9
|
-
const discord_js_1 = require("discord.js");
|
|
10
|
-
const necord_explorer_service_1 = require("../necord-explorer.service");
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { Global, Inject, Module } from '@nestjs/common';
|
|
3
|
+
import { Client } from 'discord.js';
|
|
4
|
+
import { NECORD_MODULE_OPTIONS } from '../necord.module-definition.js';
|
|
5
|
+
import { NecordExplorerService } from '../necord-explorer.service.js';
|
|
6
|
+
import { TextCommandsService } from './text-commands.service.js';
|
|
7
|
+
import { TextCommand } from './decorators/index.js';
|
|
11
8
|
let TextCommandsModule = class TextCommandsModule {
|
|
12
9
|
constructor(options, client, explorerService, textCommandsService) {
|
|
13
10
|
this.options = options;
|
|
@@ -15,9 +12,9 @@ let TextCommandsModule = class TextCommandsModule {
|
|
|
15
12
|
this.explorerService = explorerService;
|
|
16
13
|
this.textCommandsService = textCommandsService;
|
|
17
14
|
}
|
|
18
|
-
onModuleInit() {
|
|
15
|
+
async onModuleInit() {
|
|
19
16
|
return this.explorerService
|
|
20
|
-
.explore(
|
|
17
|
+
.explore(TextCommand.KEY)
|
|
21
18
|
.forEach(textCommand => this.textCommandsService.add(textCommand));
|
|
22
19
|
}
|
|
23
20
|
onApplicationBootstrap() {
|
|
@@ -28,9 +25,17 @@ let TextCommandsModule = class TextCommandsModule {
|
|
|
28
25
|
const prefix = typeof this.options.prefix !== 'function'
|
|
29
26
|
? (this.options.prefix ?? '!')
|
|
30
27
|
: await this.options.prefix(message);
|
|
31
|
-
|
|
28
|
+
let contentWithoutPrefix = '';
|
|
29
|
+
const hasPrefix = prefix && content.startsWith(prefix);
|
|
30
|
+
if (hasPrefix) {
|
|
31
|
+
contentWithoutPrefix = content.slice(prefix.length);
|
|
32
|
+
}
|
|
33
|
+
else if (this.options.allowTextCommandsWithoutPrefix) {
|
|
34
|
+
contentWithoutPrefix = content;
|
|
35
|
+
}
|
|
36
|
+
if (!contentWithoutPrefix)
|
|
32
37
|
return;
|
|
33
|
-
const args =
|
|
38
|
+
const args = contentWithoutPrefix.trim().split(/ +/g);
|
|
34
39
|
const cmd = args.shift();
|
|
35
40
|
if (!cmd)
|
|
36
41
|
return;
|
|
@@ -38,15 +43,15 @@ let TextCommandsModule = class TextCommandsModule {
|
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
exports: [text_commands_service_1.TextCommandsService]
|
|
46
|
+
TextCommandsModule = __decorate([
|
|
47
|
+
Global(),
|
|
48
|
+
Module({
|
|
49
|
+
providers: [TextCommandsService],
|
|
50
|
+
exports: [TextCommandsService]
|
|
47
51
|
}),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
__param(0, Inject(NECORD_MODULE_OPTIONS)),
|
|
53
|
+
__metadata("design:paramtypes", [Object, Client,
|
|
54
|
+
NecordExplorerService,
|
|
55
|
+
TextCommandsService])
|
|
52
56
|
], TextCommandsModule);
|
|
57
|
+
export { TextCommandsModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import { TextCommandDiscovery } from './text-command.discovery';
|
|
2
|
+
import { TextCommandDiscovery } from './text-command.discovery.js';
|
|
3
3
|
/**
|
|
4
4
|
* Service that manages text commands.
|
|
5
5
|
*/
|
|
@@ -7,6 +7,6 @@ export declare class TextCommandsService {
|
|
|
7
7
|
private readonly logger;
|
|
8
8
|
readonly cache: Collection<string, TextCommandDiscovery>;
|
|
9
9
|
add(textCommand: TextCommandDiscovery): void;
|
|
10
|
-
get(name: string): TextCommandDiscovery;
|
|
10
|
+
get(name: string): TextCommandDiscovery | undefined;
|
|
11
11
|
remove(name: string): void;
|
|
12
12
|
}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var TextCommandsService_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 text commands.
|
|
10
7
|
*/
|
|
11
8
|
let TextCommandsService = TextCommandsService_1 = class TextCommandsService {
|
|
12
9
|
constructor() {
|
|
13
|
-
this.logger = new
|
|
14
|
-
this.cache = new
|
|
10
|
+
this.logger = new Logger(TextCommandsService_1.name);
|
|
11
|
+
this.cache = new Collection();
|
|
15
12
|
}
|
|
16
13
|
add(textCommand) {
|
|
17
14
|
const name = textCommand.getName();
|
|
15
|
+
const aliases = textCommand.getAliases();
|
|
18
16
|
if (this.cache.has(name)) {
|
|
19
17
|
this.logger.warn(`TextCommand : ${name} already exists`);
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
const variants = [name, ...aliases];
|
|
20
|
+
for (const variant of variants) {
|
|
21
|
+
if (this.cache.has(variant)) {
|
|
22
|
+
this.logger.warn(`TextCommand : ${variant} already exists`);
|
|
23
|
+
}
|
|
24
|
+
this.cache.set(variant, textCommand);
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
get(name) {
|
|
24
28
|
return this.cache.get(name);
|
|
@@ -27,7 +31,7 @@ let TextCommandsService = TextCommandsService_1 = class TextCommandsService {
|
|
|
27
31
|
this.cache.delete(name);
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0, common_1.Injectable)()
|
|
34
|
+
TextCommandsService = TextCommandsService_1 = __decorate([
|
|
35
|
+
Injectable()
|
|
33
36
|
], TextCommandsService);
|
|
37
|
+
export { TextCommandsService };
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "necord",
|
|
3
3
|
"description": "A module for creating Discord bots using NestJS, based on Discord.js",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
8
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
7
9
|
"prepublish:npm": "npm run build",
|
|
8
10
|
"publish:npm": "release-it",
|
|
9
11
|
"prepublish:dev": "npm run build",
|
|
@@ -11,11 +13,12 @@
|
|
|
11
13
|
"prepare": "husky",
|
|
12
14
|
"postinstall": "opencollective",
|
|
13
15
|
"format": "prettier --write \"{src,apps,libs,test}/**/*.ts\"",
|
|
14
|
-
"lint": "
|
|
15
|
-
"test": "
|
|
16
|
-
"test:watch": "
|
|
17
|
-
"test:cov": "
|
|
18
|
-
"test:ci": "
|
|
16
|
+
"lint": "oxlint --type-aware --deny-warnings src test",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"test:cov": "vitest run --coverage",
|
|
20
|
+
"test:ci": "vitest run --coverage",
|
|
21
|
+
"test:package": "npm run build && npm pack --dry-run && node --input-type=module --eval \"await import('necord')\" && node --eval \"require('necord')\""
|
|
19
22
|
},
|
|
20
23
|
"lint-staged": {
|
|
21
24
|
"*.ts": [
|
|
@@ -40,6 +43,16 @@
|
|
|
40
43
|
},
|
|
41
44
|
"main": "./dist/index.js",
|
|
42
45
|
"types": "./dist/index.d.ts",
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"default": "./dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist"
|
|
55
|
+
],
|
|
43
56
|
"keywords": [
|
|
44
57
|
"nest",
|
|
45
58
|
"nestjs",
|
|
@@ -56,7 +69,7 @@
|
|
|
56
69
|
"homepage": "https://necord.org",
|
|
57
70
|
"repository": {
|
|
58
71
|
"type": "git",
|
|
59
|
-
"url": "https://github.com/necordjs/necord"
|
|
72
|
+
"url": "git+https://github.com/necordjs/necord.git"
|
|
60
73
|
},
|
|
61
74
|
"bugs": {
|
|
62
75
|
"url": "https://github.com/necordjs/necord/issues"
|
|
@@ -71,46 +84,42 @@
|
|
|
71
84
|
"tslib": "^2.8.1"
|
|
72
85
|
},
|
|
73
86
|
"devDependencies": {
|
|
74
|
-
"@commitlint/cli": "
|
|
75
|
-
"@commitlint/config-angular": "
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"@nestjs/
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"discord-api-types": "0.38.47",
|
|
85
|
-
"discord.js": "14.26.3",
|
|
87
|
+
"@commitlint/cli": "21.2.2",
|
|
88
|
+
"@commitlint/config-angular": "21.2.2",
|
|
89
|
+
"@nestjs/common": "12.0.1",
|
|
90
|
+
"@nestjs/core": "12.0.1",
|
|
91
|
+
"@nestjs/testing": "12.0.1",
|
|
92
|
+
"@release-it/conventional-changelog": "^12.0.0",
|
|
93
|
+
"@types/node": "26.4.0",
|
|
94
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
95
|
+
"discord-api-types": "0.38.54",
|
|
96
|
+
"discord.js": "14.27.0",
|
|
86
97
|
"eslint": "^10.0.0",
|
|
87
|
-
"eslint-
|
|
88
|
-
"eslint-plugin-
|
|
89
|
-
"eslint-plugin-prettier": "5.5.5",
|
|
90
|
-
"globals": "^17.0.0",
|
|
98
|
+
"eslint-plugin-perfectionist": "5.11.0",
|
|
99
|
+
"eslint-plugin-prettier": "5.5.6",
|
|
91
100
|
"husky": "9.1.7",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
101
|
+
"lint-staged": "17.4.1",
|
|
102
|
+
"oxlint": "1.81.0",
|
|
103
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
104
|
+
"prettier": "3.9.6",
|
|
95
105
|
"reflect-metadata": "0.2.2",
|
|
96
|
-
"release-it": "
|
|
106
|
+
"release-it": "21.0.2",
|
|
97
107
|
"rimraf": "6.1.3",
|
|
98
108
|
"rxjs": "7.8.2",
|
|
99
|
-
"ts-jest": "^29.3.2",
|
|
100
109
|
"ts-node": "10.9.2",
|
|
101
|
-
"typescript": "
|
|
102
|
-
"
|
|
110
|
+
"typescript": "7.0.2",
|
|
111
|
+
"vitest": "4.1.11"
|
|
103
112
|
},
|
|
104
113
|
"peerDependencies": {
|
|
105
|
-
"@nestjs/common": "^10.2.0 || ^11.0.0",
|
|
106
|
-
"@nestjs/core": "^10.2.0 || ^11.0.0",
|
|
114
|
+
"@nestjs/common": "^10.2.0 || ^11.0.0 || ^12.0.0",
|
|
115
|
+
"@nestjs/core": "^10.2.0 || ^11.0.0 || ^12.0.0",
|
|
107
116
|
"discord-api-types": "^0.37.99",
|
|
108
117
|
"discord.js": "^14.0.1",
|
|
109
118
|
"reflect-metadata": "^0.2.1",
|
|
110
119
|
"rxjs": "^7.2.0"
|
|
111
120
|
},
|
|
112
121
|
"engines": {
|
|
113
|
-
"node": ">=
|
|
122
|
+
"node": "^20.19.0 || >=22.13.0",
|
|
114
123
|
"npm": ">=8.6.0"
|
|
115
124
|
}
|
|
116
125
|
}
|
package/.husky/commit-msg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx commitlint --config .commitlintrc.json --edit $HUSKY_GIT_PARAMS
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx lint-staged
|