necord 6.9.1 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/dist/listeners/decorators/on.decorator.d.ts +30 -2
- package/dist/listeners/decorators/on.decorator.js +27 -7
- package/dist/listeners/decorators/once.decorator.d.ts +29 -1
- package/dist/listeners/decorators/once.decorator.js +27 -7
- package/jest.config.json +16 -0
- package/package.json +23 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.10.0](https://github.com/necordjs/necord/compare/v6.9.1...v6.10.0) (2025-08-28)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add custom listener decorator helpers ([ab0c4d0](https://github.com/necordjs/necord/commit/ab0c4d04347b067104253820aa486197aed7b284))
|
|
8
|
+
|
|
3
9
|
## [6.9.1](https://github.com/necordjs/necord/compare/v6.9.0...v6.9.1) (2025-07-17)
|
|
4
10
|
|
|
5
11
|
## [6.9.0](https://github.com/necordjs/necord/compare/v6.8.14...v6.9.0) (2025-07-12)
|
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1756420753253" clover="3.2.0">
|
|
3
|
+
<project timestamp="1756420753253" name="All files">
|
|
4
4
|
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
|
|
5
5
|
</project>
|
|
6
6
|
</coverage>
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
87
87
|
Code coverage generated by
|
|
88
88
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
89
|
-
at 2025-
|
|
89
|
+
at 2025-08-28T22:39:13.250Z
|
|
90
90
|
</div>
|
|
91
91
|
<script src="prettify.js"></script>
|
|
92
92
|
<script>
|
|
@@ -1,8 +1,36 @@
|
|
|
1
|
+
import { Listener } from './listener.decorator';
|
|
1
2
|
import { NecordEvents } from '../listener.interface';
|
|
2
3
|
/**
|
|
3
|
-
* Decorator that marks a method as a listener for discord.js client.
|
|
4
|
+
* Decorator that marks a method as a listener for the discord.js client.
|
|
4
5
|
* @param event The event name.
|
|
5
6
|
* @returns The decorated method.
|
|
6
7
|
* @url https://necord.org/listeners
|
|
7
8
|
*/
|
|
8
|
-
export declare
|
|
9
|
+
export declare function On<E = NecordEvents>(event: keyof NoInfer<E>): ReturnType<typeof Listener>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `On<CustomEvents>()` instead - This will be removed in future versions.
|
|
12
|
+
* Or use `createCustomOnDecorator<CustomEvents>()` to create a custom `On` decorator.
|
|
13
|
+
*/
|
|
14
|
+
export declare function On<K extends keyof E, E = NecordEvents>(event: K): ReturnType<typeof Listener>;
|
|
15
|
+
/**
|
|
16
|
+
* Helper to create a strongly typed `On` decorator for custom events.
|
|
17
|
+
* This is useful when you have custom events that are not part of the default `NecordEvents`.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* interface CustomEvents {
|
|
21
|
+
* myCustomEvent: [string, number];
|
|
22
|
+
* anotherEvent: [boolean];
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* const OnCustom = createCustomOnDecorator<CustomEvents>();
|
|
26
|
+
*
|
|
27
|
+
* class MyListener {
|
|
28
|
+
* @OnCustom('myCustomEvent')
|
|
29
|
+
* handleMyCustomEvent(@Context() [name, age]: [string, number]) {
|
|
30
|
+
* console.log(`Name: ${name}, Age: ${age}`);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*```
|
|
34
|
+
* @returns A strongly typed `On` decorator for custom events.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createCustomOnDecorator<Events>(): <K extends keyof Events>(event: K) => import("@nestjs/common").CustomDecorator;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.On =
|
|
3
|
+
exports.On = On;
|
|
4
|
+
exports.createCustomOnDecorator = createCustomOnDecorator;
|
|
4
5
|
const listener_decorator_1 = require("./listener.decorator");
|
|
6
|
+
function On(event) {
|
|
7
|
+
return (0, listener_decorator_1.Listener)({ type: 'on', event });
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
+
* Helper to create a strongly typed `On` decorator for custom events.
|
|
11
|
+
* This is useful when you have custom events that are not part of the default `NecordEvents`.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* interface CustomEvents {
|
|
15
|
+
* myCustomEvent: [string, number];
|
|
16
|
+
* anotherEvent: [boolean];
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* const OnCustom = createCustomOnDecorator<CustomEvents>();
|
|
20
|
+
*
|
|
21
|
+
* class MyListener {
|
|
22
|
+
* @OnCustom('myCustomEvent')
|
|
23
|
+
* handleMyCustomEvent(@Context() [name, age]: [string, number]) {
|
|
24
|
+
* console.log(`Name: ${name}, Age: ${age}`);
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*```
|
|
28
|
+
* @returns A strongly typed `On` decorator for custom events.
|
|
10
29
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
function createCustomOnDecorator() {
|
|
31
|
+
return (event) => On(event);
|
|
32
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Listener } from './listener.decorator';
|
|
1
2
|
import { NecordEvents } from '../listener.interface';
|
|
2
3
|
/**
|
|
3
4
|
* Decorator that marks a method as a listener for discord.js client.
|
|
@@ -5,4 +6,31 @@ import { NecordEvents } from '../listener.interface';
|
|
|
5
6
|
* @returns The decorated method.
|
|
6
7
|
* @url https://necord.org/listeners
|
|
7
8
|
*/
|
|
8
|
-
export declare
|
|
9
|
+
export declare function Once<E = NecordEvents>(event: keyof NoInfer<E>): ReturnType<typeof Listener>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `Once<CustomEvents>()` instead - This will be removed in future versions.
|
|
12
|
+
* Or use `createCustomOnceDecorator<CustomEvents>()` to create a custom `Once` decorator.
|
|
13
|
+
*/
|
|
14
|
+
export declare function Once<K extends keyof E, E = NecordEvents>(event: K): ReturnType<typeof Listener>;
|
|
15
|
+
/**
|
|
16
|
+
* Helper to create a strongly typed `Once` decorator for custom events.
|
|
17
|
+
* This is useful when you have custom events that are not part of the default `NecordEvents`.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* interface CustomEvents {
|
|
21
|
+
* myCustomEvent: [string, number];
|
|
22
|
+
* anotherEvent: [boolean];
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* const OnceCustom = createCustomOnceDecorator<CustomEvents>();
|
|
26
|
+
*
|
|
27
|
+
* class MyListener {
|
|
28
|
+
* @OnceCustom('myCustomEvent')
|
|
29
|
+
* handleMyCustomEvent(@Context() [name, age]: [string, number]) {
|
|
30
|
+
* console.log(`Name: ${name}, Age: ${age}`);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*```
|
|
34
|
+
* @returns A strongly typed `Once` decorator for custom events.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createCustomOnceDecorator<Events>(): <K extends keyof Events>(event: K) => import("@nestjs/common").CustomDecorator;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Once =
|
|
3
|
+
exports.Once = Once;
|
|
4
|
+
exports.createCustomOnceDecorator = createCustomOnceDecorator;
|
|
4
5
|
const listener_decorator_1 = require("./listener.decorator");
|
|
6
|
+
function Once(event) {
|
|
7
|
+
return (0, listener_decorator_1.Listener)({ type: 'once', event });
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
+
* Helper to create a strongly typed `Once` decorator for custom events.
|
|
11
|
+
* This is useful when you have custom events that are not part of the default `NecordEvents`.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* interface CustomEvents {
|
|
15
|
+
* myCustomEvent: [string, number];
|
|
16
|
+
* anotherEvent: [boolean];
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* const OnceCustom = createCustomOnceDecorator<CustomEvents>();
|
|
20
|
+
*
|
|
21
|
+
* class MyListener {
|
|
22
|
+
* @OnceCustom('myCustomEvent')
|
|
23
|
+
* handleMyCustomEvent(@Context() [name, age]: [string, number]) {
|
|
24
|
+
* console.log(`Name: ${name}, Age: ${age}`);
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*```
|
|
28
|
+
* @returns A strongly typed `Once` decorator for custom events.
|
|
10
29
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
function createCustomOnceDecorator() {
|
|
31
|
+
return (event) => Once(event);
|
|
32
|
+
}
|
package/jest.config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": [
|
|
3
|
+
"js",
|
|
4
|
+
"json",
|
|
5
|
+
"ts"
|
|
6
|
+
],
|
|
7
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
8
|
+
"transform": {
|
|
9
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
10
|
+
},
|
|
11
|
+
"testEnvironment": "node",
|
|
12
|
+
"coverageDirectory": "./coverage",
|
|
13
|
+
"collectCoverageFrom": [
|
|
14
|
+
"src/**/*.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "necord",
|
|
3
3
|
"description": "A module for creating Discord bots using NestJS, based on Discord.js",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.10.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
7
7
|
"prepublish:npm": "npm run build",
|
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
"publish:dev": "npm publish --access public --tag dev",
|
|
11
11
|
"prepare": "husky",
|
|
12
12
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
13
|
-
"lint": "eslint --ignore-pattern .gitignore src/**/*.ts"
|
|
13
|
+
"lint": "eslint --ignore-pattern .gitignore src/**/*.ts",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"test:watch": "jest --watch",
|
|
16
|
+
"test:cov": "jest --coverage",
|
|
17
|
+
"test:ci": "jest --ci --passWithNoTests --coverage"
|
|
14
18
|
},
|
|
15
19
|
"lint-staged": {
|
|
16
|
-
"*.ts":
|
|
20
|
+
"*.ts": [
|
|
21
|
+
"npm run format",
|
|
22
|
+
"npm run test:ci"
|
|
23
|
+
]
|
|
17
24
|
},
|
|
18
25
|
"directories": {
|
|
19
26
|
"lib": "src",
|
|
@@ -59,26 +66,30 @@
|
|
|
59
66
|
"@eslint/eslintrc": "^3.2.0",
|
|
60
67
|
"@eslint/js": "^9.18.0",
|
|
61
68
|
"@favware/npm-deprecate": "2.0.0",
|
|
62
|
-
"@nestjs/common": "11.1.
|
|
63
|
-
"@nestjs/core": "11.1.
|
|
69
|
+
"@nestjs/common": "11.1.6",
|
|
70
|
+
"@nestjs/core": "11.1.6",
|
|
71
|
+
"@nestjs/testing": "^11.1.5",
|
|
64
72
|
"@release-it/conventional-changelog": "^10.0.0",
|
|
65
|
-
"@types/
|
|
66
|
-
"
|
|
67
|
-
"discord
|
|
73
|
+
"@types/jest": "^30.0.0",
|
|
74
|
+
"@types/node": "24.3.0",
|
|
75
|
+
"discord-api-types": "0.38.21",
|
|
76
|
+
"discord.js": "14.22.1",
|
|
68
77
|
"eslint": "^9.18.0",
|
|
69
|
-
"eslint-config-prettier": "10.1.
|
|
78
|
+
"eslint-config-prettier": "10.1.8",
|
|
70
79
|
"eslint-plugin-import": "^2.31.0",
|
|
71
|
-
"eslint-plugin-prettier": "5.5.
|
|
80
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
72
81
|
"globals": "^16.0.0",
|
|
73
82
|
"husky": "9.1.7",
|
|
74
|
-
"
|
|
83
|
+
"jest": "^30.0.5",
|
|
84
|
+
"lint-staged": "16.1.5",
|
|
75
85
|
"prettier": "3.6.2",
|
|
76
86
|
"reflect-metadata": "0.2.2",
|
|
77
87
|
"release-it": "19.0.4",
|
|
78
88
|
"rimraf": "6.0.1",
|
|
79
89
|
"rxjs": "7.8.2",
|
|
90
|
+
"ts-jest": "^29.4.1",
|
|
80
91
|
"ts-node": "10.9.2",
|
|
81
|
-
"typescript": "5.
|
|
92
|
+
"typescript": "5.9.2",
|
|
82
93
|
"typescript-eslint": "^8.21.0"
|
|
83
94
|
},
|
|
84
95
|
"peerDependencies": {
|