necord 2.0.0 → 2.0.1-dev.1638838131.9492061
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/README.md +65 -9
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +16 -16
- package/dist/context/necord-arguments-host.d.ts +11 -11
- package/dist/context/necord-arguments-host.js +19 -19
- package/dist/context/necord-execution-context.d.ts +8 -8
- package/dist/context/necord-execution-context.js +19 -19
- package/dist/context/necord-params.factory.d.ts +5 -5
- package/dist/context/necord-params.factory.js +25 -25
- package/dist/context/necord-paramtype.enum.d.ts +6 -6
- package/dist/context/necord-paramtype.enum.js +10 -10
- package/dist/decorators/{necord-commands.decorator.d.ts → commands.decorator.d.ts} +10 -10
- package/dist/decorators/{necord-commands.decorator.js → commands.decorator.js} +7 -7
- package/dist/decorators/{necord-components.decorator.d.ts → components.decorator.d.ts} +2 -2
- package/dist/decorators/{necord-components.decorator.js → components.decorator.js} +6 -6
- package/dist/decorators/{necord-groups.decorator.d.ts → groups.decorator.d.ts} +3 -3
- package/dist/decorators/{necord-groups.decorator.js → groups.decorator.js} +9 -9
- package/dist/decorators/index.d.ts +6 -6
- package/dist/decorators/index.js +18 -18
- package/dist/decorators/{necord-listeners.decorator.d.ts → listeners.decorator.d.ts} +2 -2
- package/dist/decorators/{necord-listeners.decorator.js → listeners.decorator.js} +6 -6
- package/dist/decorators/{necord-options.decorator.d.ts → options.decorator.d.ts} +37 -37
- package/dist/decorators/{necord-options.decorator.js → options.decorator.js} +13 -13
- package/dist/decorators/{necord-params.decorator.d.ts → params.decorator.d.ts} +4 -4
- package/dist/decorators/{necord-params.decorator.js → params.decorator.js} +16 -16
- package/dist/index.d.ts +4 -6
- package/dist/index.js +16 -18
- package/dist/interfaces/command-metadata.interface.d.ts +6 -3
- package/dist/interfaces/command-metadata.interface.js +2 -2
- package/dist/interfaces/component-metadata.interface.d.ts +5 -6
- package/dist/interfaces/component-metadata.interface.js +2 -2
- package/dist/interfaces/index.d.ts +5 -6
- package/dist/interfaces/index.js +17 -18
- package/dist/interfaces/listener-metadata.interface.d.ts +5 -6
- package/dist/interfaces/listener-metadata.interface.js +2 -2
- package/dist/interfaces/module-options.interface.d.ts +16 -16
- package/dist/interfaces/module-options.interface.js +2 -2
- package/dist/interfaces/option-metadata.interface.d.ts +7 -7
- package/dist/interfaces/option-metadata.interface.js +2 -2
- package/dist/necord.constants.d.ts +8 -7
- package/dist/necord.constants.js +12 -11
- package/dist/necord.module.d.ts +14 -8
- package/dist/necord.module.js +107 -81
- package/dist/services/commands.service.d.ts +19 -0
- package/dist/services/{commands-explorer.service.js → commands.service.js} +168 -148
- package/dist/services/components.service.d.ts +13 -0
- package/dist/services/components.service.js +40 -0
- package/dist/services/explorer.service.d.ts +17 -0
- package/dist/services/explorer.service.js +54 -0
- package/dist/services/index.d.ts +5 -4
- package/dist/services/index.js +17 -16
- package/dist/services/listeners.service.d.ts +12 -0
- package/dist/services/listeners.service.js +47 -0
- package/dist/services/metadata-accessor.service.d.ts +13 -13
- package/dist/services/metadata-accessor.service.js +44 -44
- package/dist/utils/create-necord-commands.util.d.ts +4 -4
- package/dist/utils/create-necord-commands.util.js +9 -9
- package/dist/utils/create-necord-components.util.d.ts +2 -2
- package/dist/utils/create-necord-components.util.js +9 -9
- package/dist/utils/create-necord-listeners.util.d.ts +3 -2
- package/dist/utils/create-necord-listeners.util.js +12 -12
- package/dist/utils/create-necord-options.util.d.ts +2 -2
- package/dist/utils/create-necord-options.util.js +15 -15
- package/dist/utils/create-necord-params.util.d.ts +4 -4
- package/dist/utils/create-necord-params.util.js +24 -24
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.js +17 -17
- package/package.json +30 -40
- package/dist/interfaces/method-metadata.interface.d.ts +0 -5
- package/dist/interfaces/method-metadata.interface.js +0 -2
- package/dist/necord-client.d.ts +0 -13
- package/dist/necord-client.js +0 -69
- package/dist/providers/application-commands.provider.d.ts +0 -4
- package/dist/providers/application-commands.provider.js +0 -8
- package/dist/providers/index.d.ts +0 -3
- package/dist/providers/index.js +0 -15
- package/dist/providers/message-components.provider.d.ts +0 -4
- package/dist/providers/message-components.provider.js +0 -9
- package/dist/providers/module-options.provider.d.ts +0 -4
- package/dist/providers/module-options.provider.js +0 -9
- package/dist/services/base-explorer.service.d.ts +0 -15
- package/dist/services/base-explorer.service.js +0 -35
- package/dist/services/commands-explorer.service.d.ts +0 -19
- package/dist/services/components-explorer.service.d.ts +0 -16
- package/dist/services/components-explorer.service.js +0 -57
- package/dist/services/listeners-explorer.service.d.ts +0 -16
- package/dist/services/listeners-explorer.service.js +0 -54
- package/dist/test/app.commands.d.ts +0 -11
- package/dist/test/app.commands.js +0 -143
- package/dist/test/app.module.d.ts +0 -2
- package/dist/test/app.module.js +0 -28
- package/dist/test/dtos/register.dto.d.ts +0 -7
- package/dist/test/dtos/register.dto.js +0 -52
- package/dist/test/main.d.ts +0 -1
- package/dist/test/main.js +0 -5
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<a href='https://img.shields.io/npm/v/necord'><img src="https://img.shields.io/npm/v/necord" alt="NPM Version" /></a>
|
|
10
10
|
<a href='https://img.shields.io/npm/l/necord'><img src="https://img.shields.io/npm/l/necord" alt="NPM License" /></a>
|
|
11
11
|
<a href='https://img.shields.io/npm/dm/necord'><img src="https://img.shields.io/npm/dm/necord" alt="NPM Downloads" /></a>
|
|
12
|
-
<a href='https://img.shields.io/github/last-commit/SocketSomeone/necord'><img src="https://img.shields.io/github/last-commit/SocketSomeone/necord" alt="Last
|
|
12
|
+
<a href='https://img.shields.io/github/last-commit/SocketSomeone/necord'><img src="https://img.shields.io/github/last-commit/SocketSomeone/necord" alt="Last commit" /></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
## About
|
|
@@ -20,26 +20,82 @@ This module provides fast and easy way for creating Discord bots and deep integr
|
|
|
20
20
|
|
|
21
21
|
**Features**
|
|
22
22
|
|
|
23
|
-
- Simple. Easy to use.
|
|
23
|
+
- Simple. Flexible. Easy to use.
|
|
24
24
|
- Ability to create custom decorators.
|
|
25
25
|
- Interact with Discord (Slash Commands, Context Menus, Message Components, Listeners).
|
|
26
26
|
- Full support of NestJS guards, interceptors, filters and pipes!
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
For questions and support please use
|
|
29
|
+
the [Issues](https://github.com/SocketSomeone/necord/issues/new?assignees=&labels=question&template=question.yml).
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
## Installation
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
**Node.js 16.6.0 or newer is required.**
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
```bash
|
|
36
|
+
$ npm i necord discord.js
|
|
37
|
+
$ yarn add necord discord.js
|
|
38
|
+
$ pnpm add necord discord.js
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
Once the installation process is complete, we can import the `NecordModule` into the root `AppModule`:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { NecordModule } from 'necord';
|
|
47
|
+
import { Module } from '@nestjs/common';
|
|
48
|
+
import { Intents } from 'discord.js';
|
|
49
|
+
|
|
50
|
+
@Module({
|
|
51
|
+
imports: [
|
|
52
|
+
NecordModule.forRoot({
|
|
53
|
+
token: 'DISCORD_BOT_TOKEN',
|
|
54
|
+
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES]
|
|
55
|
+
})
|
|
56
|
+
],
|
|
57
|
+
providers: []
|
|
58
|
+
})
|
|
59
|
+
export class AppModule {
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then create `app.update.ts` file and add `On`/`Once` decorators for handling Discord API events:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
67
|
+
import { Context, On, Once } from 'necord';
|
|
68
|
+
|
|
69
|
+
@Injectable()
|
|
70
|
+
export class AppUpdate {
|
|
71
|
+
private readonly logger = new Logger(AppUpdate.name);
|
|
72
|
+
|
|
73
|
+
@Once('ready')
|
|
74
|
+
public onReady(@Context() client: Client) {
|
|
75
|
+
this.logger.log(`Bot logged in as ${client.user.username}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@On('warn')
|
|
79
|
+
public onWarn(@Context() message: string) {
|
|
80
|
+
this.logger.warn(message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Whenever you need to handle any event data, use the `Context` decorator.
|
|
86
|
+
|
|
87
|
+
If you want to fully dive into Necord check out these resources:
|
|
88
|
+
|
|
89
|
+
* [Necord Wiki](https://github.com/SocketSomeone/necord/wiki) - Official documentation of Necord.
|
|
90
|
+
* [Nest JS](https://docs.nestjs.com) - A progressive framework for creating well-architectured applications.
|
|
91
|
+
* [Discord JS](https://discord.js.org) - The most powerful library for creating bots.
|
|
92
|
+
* [Discord API](https://discord.com/developers/docs) - Official documentation of Discord API.
|
|
36
93
|
|
|
37
94
|
## Stay in touch
|
|
38
95
|
|
|
39
96
|
* Author - [Alexey Filippov](https://t.me/socketsomeone)
|
|
40
|
-
* Documentation - https://necord.miko.bot
|
|
41
97
|
* Twitter - [@SocketSomeone](https://twitter.com/SocketSomeone)
|
|
42
98
|
|
|
43
99
|
## License
|
|
44
100
|
|
|
45
|
-
|
|
101
|
+
[MIT](https://github.com/SocketSomeone/necord/blob/master/LICENSE) © [Alexey Filippov](https://github.com/SocketSomeone)
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './necord-arguments-host';
|
|
2
|
-
export * from './necord-execution-context';
|
|
3
|
-
export * from './necord-paramtype.enum';
|
|
4
|
-
export * from './necord-params.factory';
|
|
1
|
+
export * from './necord-arguments-host';
|
|
2
|
+
export * from './necord-execution-context';
|
|
3
|
+
export * from './necord-paramtype.enum';
|
|
4
|
+
export * from './necord-params.factory';
|
package/dist/context/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./necord-arguments-host"), exports);
|
|
14
|
-
__exportStar(require("./necord-execution-context"), exports);
|
|
15
|
-
__exportStar(require("./necord-paramtype.enum"), exports);
|
|
16
|
-
__exportStar(require("./necord-params.factory"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./necord-arguments-host"), exports);
|
|
14
|
+
__exportStar(require("./necord-execution-context"), exports);
|
|
15
|
+
__exportStar(require("./necord-paramtype.enum"), exports);
|
|
16
|
+
__exportStar(require("./necord-params.factory"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
|
|
2
|
-
import { ArgumentsHost } from '@nestjs/common';
|
|
3
|
-
import { NecordContextType } from './necord-execution-context';
|
|
4
|
-
export interface INecordArgumentsHost extends ArgumentsHost {
|
|
5
|
-
getContext<T = any>(): T;
|
|
6
|
-
}
|
|
7
|
-
export declare class NecordArgumentsHost extends ExecutionContextHost implements INecordArgumentsHost {
|
|
8
|
-
static create(context: ArgumentsHost): NecordArgumentsHost;
|
|
9
|
-
getType<TContext extends string = NecordContextType>(): TContext;
|
|
10
|
-
getContext<T = any>(): T;
|
|
11
|
-
}
|
|
1
|
+
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
|
|
2
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
3
|
+
import { NecordContextType } from './necord-execution-context';
|
|
4
|
+
export interface INecordArgumentsHost extends ArgumentsHost {
|
|
5
|
+
getContext<T = any>(): T;
|
|
6
|
+
}
|
|
7
|
+
export declare class NecordArgumentsHost extends ExecutionContextHost implements INecordArgumentsHost {
|
|
8
|
+
static create(context: ArgumentsHost): NecordArgumentsHost;
|
|
9
|
+
getType<TContext extends string = NecordContextType>(): TContext;
|
|
10
|
+
getContext<T = any>(): T;
|
|
11
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NecordArgumentsHost = void 0;
|
|
4
|
-
const execution_context_host_1 = require("@nestjs/core/helpers/execution-context-host");
|
|
5
|
-
class NecordArgumentsHost extends execution_context_host_1.ExecutionContextHost {
|
|
6
|
-
static create(context) {
|
|
7
|
-
const type = context.getType();
|
|
8
|
-
const necContext = new NecordArgumentsHost(context.getArgs());
|
|
9
|
-
necContext.setType(type);
|
|
10
|
-
return necContext;
|
|
11
|
-
}
|
|
12
|
-
getType() {
|
|
13
|
-
return super.getType();
|
|
14
|
-
}
|
|
15
|
-
getContext() {
|
|
16
|
-
return this.getArgByIndex(0);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.NecordArgumentsHost = NecordArgumentsHost;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NecordArgumentsHost = void 0;
|
|
4
|
+
const execution_context_host_1 = require("@nestjs/core/helpers/execution-context-host");
|
|
5
|
+
class NecordArgumentsHost extends execution_context_host_1.ExecutionContextHost {
|
|
6
|
+
static create(context) {
|
|
7
|
+
const type = context.getType();
|
|
8
|
+
const necContext = new NecordArgumentsHost(context.getArgs());
|
|
9
|
+
necContext.setType(type);
|
|
10
|
+
return necContext;
|
|
11
|
+
}
|
|
12
|
+
getType() {
|
|
13
|
+
return super.getType();
|
|
14
|
+
}
|
|
15
|
+
getContext() {
|
|
16
|
+
return this.getArgByIndex(0);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.NecordArgumentsHost = NecordArgumentsHost;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ContextType, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { NecordArgumentsHost } from './necord-arguments-host';
|
|
3
|
-
export declare type NecordContextType = 'necord' | ContextType;
|
|
4
|
-
export declare class NecordExecutionContext extends NecordArgumentsHost {
|
|
5
|
-
static create(context: ExecutionContext): NecordExecutionContext;
|
|
6
|
-
getType<TContext extends string = NecordContextType>(): TContext;
|
|
7
|
-
getContext<T = any>(): T;
|
|
8
|
-
}
|
|
1
|
+
import { ContextType, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { NecordArgumentsHost } from './necord-arguments-host';
|
|
3
|
+
export declare type NecordContextType = 'necord' | ContextType;
|
|
4
|
+
export declare class NecordExecutionContext extends NecordArgumentsHost {
|
|
5
|
+
static create(context: ExecutionContext): NecordExecutionContext;
|
|
6
|
+
getType<TContext extends string = NecordContextType>(): TContext;
|
|
7
|
+
getContext<T = any>(): T;
|
|
8
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NecordExecutionContext = void 0;
|
|
4
|
-
const necord_arguments_host_1 = require("./necord-arguments-host");
|
|
5
|
-
class NecordExecutionContext extends necord_arguments_host_1.NecordArgumentsHost {
|
|
6
|
-
static create(context) {
|
|
7
|
-
const type = context.getType();
|
|
8
|
-
const necContext = new NecordExecutionContext(context.getArgs(), context.getClass(), context.getHandler());
|
|
9
|
-
necContext.setType(type);
|
|
10
|
-
return necContext;
|
|
11
|
-
}
|
|
12
|
-
getType() {
|
|
13
|
-
return super.getType();
|
|
14
|
-
}
|
|
15
|
-
getContext() {
|
|
16
|
-
return this.getArgByIndex(0);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.NecordExecutionContext = NecordExecutionContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NecordExecutionContext = void 0;
|
|
4
|
+
const necord_arguments_host_1 = require("./necord-arguments-host");
|
|
5
|
+
class NecordExecutionContext extends necord_arguments_host_1.NecordArgumentsHost {
|
|
6
|
+
static create(context) {
|
|
7
|
+
const type = context.getType();
|
|
8
|
+
const necContext = new NecordExecutionContext(context.getArgs(), context.getClass(), context.getHandler());
|
|
9
|
+
necContext.setType(type);
|
|
10
|
+
return necContext;
|
|
11
|
+
}
|
|
12
|
+
getType() {
|
|
13
|
+
return super.getType();
|
|
14
|
+
}
|
|
15
|
+
getContext() {
|
|
16
|
+
return this.getArgByIndex(0);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.NecordExecutionContext = NecordExecutionContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
|
|
2
|
-
import { ParamData } from '@nestjs/common';
|
|
3
|
-
export declare class NecordParamsFactory implements ParamsFactory {
|
|
4
|
-
exchangeKeyForValue(type: number, data: ParamData, args: unknown): any;
|
|
5
|
-
}
|
|
1
|
+
import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
|
|
2
|
+
import { ParamData } from '@nestjs/common';
|
|
3
|
+
export declare class NecordParamsFactory implements ParamsFactory {
|
|
4
|
+
exchangeKeyForValue(type: number, data: ParamData, args: unknown): any;
|
|
5
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NecordParamsFactory = void 0;
|
|
4
|
-
const necord_paramtype_enum_1 = require("./necord-paramtype.enum");
|
|
5
|
-
class NecordParamsFactory {
|
|
6
|
-
exchangeKeyForValue(type, data, args) {
|
|
7
|
-
if (!args) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const context = args[0];
|
|
11
|
-
switch (type) {
|
|
12
|
-
case necord_paramtype_enum_1.NecordParamType.CONTEXT:
|
|
13
|
-
return data ? context[data] : context;
|
|
14
|
-
case necord_paramtype_enum_1.NecordParamType.OPTIONS:
|
|
15
|
-
return context.isApplicationCommand() ? (!!data ? args[1][data] : args[1]) : null;
|
|
16
|
-
case necord_paramtype_enum_1.NecordParamType.VALUES:
|
|
17
|
-
return context.isSelectMenu() ? context.values : null;
|
|
18
|
-
case necord_paramtype_enum_1.NecordParamType.COMPONENT:
|
|
19
|
-
return context.isMessageComponent() ? context.component : null;
|
|
20
|
-
default:
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.NecordParamsFactory = NecordParamsFactory;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NecordParamsFactory = void 0;
|
|
4
|
+
const necord_paramtype_enum_1 = require("./necord-paramtype.enum");
|
|
5
|
+
class NecordParamsFactory {
|
|
6
|
+
exchangeKeyForValue(type, data, args) {
|
|
7
|
+
if (!args) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const context = args[0];
|
|
11
|
+
switch (type) {
|
|
12
|
+
case necord_paramtype_enum_1.NecordParamType.CONTEXT:
|
|
13
|
+
return data ? context[data] : context;
|
|
14
|
+
case necord_paramtype_enum_1.NecordParamType.OPTIONS:
|
|
15
|
+
return context.isApplicationCommand() ? (!!data ? args[1][data] : args[1]) : null;
|
|
16
|
+
case necord_paramtype_enum_1.NecordParamType.VALUES:
|
|
17
|
+
return context.isSelectMenu() ? context.values : null;
|
|
18
|
+
case necord_paramtype_enum_1.NecordParamType.COMPONENT:
|
|
19
|
+
return context.isMessageComponent() ? context.component : null;
|
|
20
|
+
default:
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.NecordParamsFactory = NecordParamsFactory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare enum NecordParamType {
|
|
2
|
-
CONTEXT = 0,
|
|
3
|
-
VALUES = 1,
|
|
4
|
-
OPTIONS = 2,
|
|
5
|
-
COMPONENT = 3
|
|
6
|
-
}
|
|
1
|
+
export declare enum NecordParamType {
|
|
2
|
+
CONTEXT = 0,
|
|
3
|
+
VALUES = 1,
|
|
4
|
+
OPTIONS = 2,
|
|
5
|
+
COMPONENT = 3
|
|
6
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NecordParamType = void 0;
|
|
4
|
-
var NecordParamType;
|
|
5
|
-
(function (NecordParamType) {
|
|
6
|
-
NecordParamType[NecordParamType["CONTEXT"] = 0] = "CONTEXT";
|
|
7
|
-
NecordParamType[NecordParamType["VALUES"] = 1] = "VALUES";
|
|
8
|
-
NecordParamType[NecordParamType["OPTIONS"] = 2] = "OPTIONS";
|
|
9
|
-
NecordParamType[NecordParamType["COMPONENT"] = 3] = "COMPONENT";
|
|
10
|
-
})(NecordParamType = exports.NecordParamType || (exports.NecordParamType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NecordParamType = void 0;
|
|
4
|
+
var NecordParamType;
|
|
5
|
+
(function (NecordParamType) {
|
|
6
|
+
NecordParamType[NecordParamType["CONTEXT"] = 0] = "CONTEXT";
|
|
7
|
+
NecordParamType[NecordParamType["VALUES"] = 1] = "VALUES";
|
|
8
|
+
NecordParamType[NecordParamType["OPTIONS"] = 2] = "OPTIONS";
|
|
9
|
+
NecordParamType[NecordParamType["COMPONENT"] = 3] = "COMPONENT";
|
|
10
|
+
})(NecordParamType = exports.NecordParamType || (exports.NecordParamType = {}));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ApplicationCommandTypes } from 'discord.js/typings/enums';
|
|
2
|
-
export declare const SlashCommand: (options: Omit<import("discord.js").ChatInputApplicationCommandData & {
|
|
3
|
-
type: ApplicationCommandTypes.CHAT_INPUT;
|
|
4
|
-
}, "type" | "options">) => MethodDecorator;
|
|
5
|
-
export declare const UserCommand: (options: Omit<import("discord.js").UserApplicationCommandData & {
|
|
6
|
-
type: ApplicationCommandTypes.USER;
|
|
7
|
-
}, "type" | "options">) => MethodDecorator;
|
|
8
|
-
export declare const MessageCommand: (options: Omit<import("discord.js").MessageApplicationCommandData & {
|
|
9
|
-
type: ApplicationCommandTypes.MESSAGE;
|
|
10
|
-
}, "type" | "options">) => MethodDecorator;
|
|
1
|
+
import { ApplicationCommandTypes } from 'discord.js/typings/enums';
|
|
2
|
+
export declare const SlashCommand: (options: Omit<import("discord.js").ChatInputApplicationCommandData & {
|
|
3
|
+
type: ApplicationCommandTypes.CHAT_INPUT;
|
|
4
|
+
}, "type" | "options">) => MethodDecorator;
|
|
5
|
+
export declare const UserCommand: (options: Omit<import("discord.js").UserApplicationCommandData & {
|
|
6
|
+
type: ApplicationCommandTypes.USER;
|
|
7
|
+
}, "type" | "options">) => MethodDecorator;
|
|
8
|
+
export declare const MessageCommand: (options: Omit<import("discord.js").MessageApplicationCommandData & {
|
|
9
|
+
type: ApplicationCommandTypes.MESSAGE;
|
|
10
|
+
}, "type" | "options">) => MethodDecorator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageCommand = exports.UserCommand = exports.SlashCommand = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
exports.SlashCommand = (0, utils_1.createNecordCommandDecorator)(1 /* CHAT_INPUT */);
|
|
6
|
-
exports.UserCommand = (0, utils_1.createNecordCommandDecorator)(2 /* USER */);
|
|
7
|
-
exports.MessageCommand = (0, utils_1.createNecordCommandDecorator)(3 /* MESSAGE */);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommand = exports.UserCommand = exports.SlashCommand = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
exports.SlashCommand = (0, utils_1.createNecordCommandDecorator)(1 /* CHAT_INPUT */);
|
|
6
|
+
exports.UserCommand = (0, utils_1.createNecordCommandDecorator)(2 /* USER */);
|
|
7
|
+
exports.MessageCommand = (0, utils_1.createNecordCommandDecorator)(3 /* MESSAGE */);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const Button: (customId: string) => MethodDecorator;
|
|
2
|
-
export declare const SelectMenu: (customId: string) => MethodDecorator;
|
|
1
|
+
export declare const Button: (customId: string) => MethodDecorator;
|
|
2
|
+
export declare const SelectMenu: (customId: string) => MethodDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectMenu = exports.Button = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
exports.Button = (0, utils_1.createNecordComponentDecorator)(2 /* BUTTON */);
|
|
6
|
-
exports.SelectMenu = (0, utils_1.createNecordComponentDecorator)(3 /* SELECT_MENU */);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectMenu = exports.Button = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
exports.Button = (0, utils_1.createNecordComponentDecorator)(2 /* BUTTON */);
|
|
6
|
+
exports.SelectMenu = (0, utils_1.createNecordComponentDecorator)(3 /* SELECT_MENU */);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ApplicationCommandSubGroupData, ChatInputApplicationCommandData } from 'discord.js';
|
|
2
|
-
export declare const CommandGroup: (data?: Omit<ChatInputApplicationCommandData, 'type' | 'options'>) => import("@nestjs/common").CustomDecorator<string>;
|
|
3
|
-
export declare const CommandSubGroup: (data?: Omit<ApplicationCommandSubGroupData, 'type' | 'options'>) => import("@nestjs/common").CustomDecorator<string>;
|
|
1
|
+
import { ApplicationCommandSubGroupData, ChatInputApplicationCommandData } from 'discord.js';
|
|
2
|
+
export declare const CommandGroup: (data?: Omit<ChatInputApplicationCommandData, 'type' | 'options'>) => import("@nestjs/common").CustomDecorator<string>;
|
|
3
|
+
export declare const CommandSubGroup: (data?: Omit<ApplicationCommandSubGroupData, 'type' | 'options'>) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandSubGroup = exports.CommandGroup = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const necord_constants_1 = require("../necord.constants");
|
|
6
|
-
const CommandGroup = (data) => (0, common_1.SetMetadata)(necord_constants_1.GROUP_METADATA, Object.assign({ type: 1 /* CHAT_INPUT */, options: [] }, data));
|
|
7
|
-
exports.CommandGroup = CommandGroup;
|
|
8
|
-
const CommandSubGroup = (data) => (0, common_1.SetMetadata)(necord_constants_1.SUBGROUP_METADATA, Object.assign({ type: 2 /* SUB_COMMAND_GROUP */, options: [] }, data));
|
|
9
|
-
exports.CommandSubGroup = CommandSubGroup;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandSubGroup = exports.CommandGroup = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const CommandGroup = (data) => (0, common_1.SetMetadata)(necord_constants_1.GROUP_METADATA, Object.assign({ type: 1 /* CHAT_INPUT */, options: [] }, data));
|
|
7
|
+
exports.CommandGroup = CommandGroup;
|
|
8
|
+
const CommandSubGroup = (data) => (0, common_1.SetMetadata)(necord_constants_1.SUBGROUP_METADATA, Object.assign({ type: 2 /* SUB_COMMAND_GROUP */, options: [] }, data));
|
|
9
|
+
exports.CommandSubGroup = CommandSubGroup;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './commands.decorator';
|
|
2
|
+
export * from './components.decorator';
|
|
3
|
+
export * from './groups.decorator';
|
|
4
|
+
export * from './listeners.decorator';
|
|
5
|
+
export * from './options.decorator';
|
|
6
|
+
export * from './params.decorator';
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./
|
|
16
|
-
__exportStar(require("./
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./commands.decorator"), exports);
|
|
14
|
+
__exportStar(require("./components.decorator"), exports);
|
|
15
|
+
__exportStar(require("./groups.decorator"), exports);
|
|
16
|
+
__exportStar(require("./listeners.decorator"), exports);
|
|
17
|
+
__exportStar(require("./options.decorator"), exports);
|
|
18
|
+
__exportStar(require("./params.decorator"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const On: (event: keyof import("discord.js").ClientEvents) => MethodDecorator;
|
|
2
|
-
export declare const Once: (event: keyof import("discord.js").ClientEvents) => MethodDecorator;
|
|
1
|
+
export declare const On: (event: keyof import("discord.js").ClientEvents) => MethodDecorator;
|
|
2
|
+
export declare const Once: (event: keyof import("discord.js").ClientEvents) => MethodDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Once = exports.On = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
exports.On = (0, utils_1.createNecordListenerDecorator)(
|
|
6
|
-
exports.Once = (0, utils_1.createNecordListenerDecorator)(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Once = exports.On = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
exports.On = (0, utils_1.createNecordListenerDecorator)('on');
|
|
6
|
+
exports.Once = (0, utils_1.createNecordListenerDecorator)('once');
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { ApplicationCommandOptionTypes } from 'discord.js/typings/enums';
|
|
2
|
-
export declare const BooleanOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
3
|
-
readonly type?: ApplicationCommandOptionTypes.BOOLEAN;
|
|
4
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
5
|
-
}, "type" | "
|
|
6
|
-
export declare const IntegerOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
7
|
-
readonly type?: ApplicationCommandOptionTypes.INTEGER;
|
|
8
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
9
|
-
}, "type" | "
|
|
10
|
-
export declare const NumberOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
11
|
-
readonly type?: ApplicationCommandOptionTypes.NUMBER;
|
|
12
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
13
|
-
}, "type" | "
|
|
14
|
-
export declare const StringOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
15
|
-
readonly type?: ApplicationCommandOptionTypes.STRING;
|
|
16
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
17
|
-
}, "type" | "
|
|
18
|
-
export declare const UserOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
19
|
-
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
20
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
21
|
-
}, "type" | "
|
|
22
|
-
export declare const MemberOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
23
|
-
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
24
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
25
|
-
}, "type" | "
|
|
26
|
-
export declare const ChannelOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
27
|
-
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
28
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
29
|
-
}, "type" | "
|
|
30
|
-
export declare const RoleOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
31
|
-
readonly type?: ApplicationCommandOptionTypes.ROLE;
|
|
32
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
33
|
-
}, "type" | "
|
|
34
|
-
export declare const MentionableOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
35
|
-
readonly type?: ApplicationCommandOptionTypes.MENTIONABLE;
|
|
36
|
-
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
37
|
-
}, "type" | "
|
|
1
|
+
import { ApplicationCommandOptionTypes } from 'discord.js/typings/enums';
|
|
2
|
+
export declare const BooleanOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
3
|
+
readonly type?: ApplicationCommandOptionTypes.BOOLEAN;
|
|
4
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
5
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
6
|
+
export declare const IntegerOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
7
|
+
readonly type?: ApplicationCommandOptionTypes.INTEGER;
|
|
8
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
9
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
10
|
+
export declare const NumberOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
11
|
+
readonly type?: ApplicationCommandOptionTypes.NUMBER;
|
|
12
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
13
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
14
|
+
export declare const StringOption: (data: Omit<import("discord.js").ApplicationCommandChoicesData & {
|
|
15
|
+
readonly type?: ApplicationCommandOptionTypes.STRING;
|
|
16
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
17
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
18
|
+
export declare const UserOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
19
|
+
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
20
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
21
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
22
|
+
export declare const MemberOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
23
|
+
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
24
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
25
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
26
|
+
export declare const ChannelOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
27
|
+
readonly type?: ApplicationCommandOptionTypes.USER;
|
|
28
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
29
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
30
|
+
export declare const RoleOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
31
|
+
readonly type?: ApplicationCommandOptionTypes.ROLE;
|
|
32
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
33
|
+
}, "type" | "methodName">) => PropertyDecorator;
|
|
34
|
+
export declare const MentionableOption: (data: Omit<import("discord.js").ApplicationCommandNonOptionsData & {
|
|
35
|
+
readonly type?: ApplicationCommandOptionTypes.MENTIONABLE;
|
|
36
|
+
methodName?: keyof import("discord.js").CommandInteractionOptionResolver<import("discord.js").CacheType>;
|
|
37
|
+
}, "type" | "methodName">) => PropertyDecorator;
|