necord 4.2.6 → 5.0.0-dev.1651543568.b9cd2c9
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 +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +20 -16
- package/dist/context/necord-arguments-host.d.ts +20 -15
- package/dist/context/necord-arguments-host.js +28 -25
- package/dist/context/necord-context-creator.d.ts +9 -0
- package/dist/context/necord-context-creator.js +33 -0
- package/dist/context/necord-execution-context.d.ts +6 -6
- package/dist/context/necord-execution-context.js +13 -13
- package/dist/context/necord-params.factory.d.ts +11 -10
- package/dist/context/necord-params.factory.js +29 -26
- package/dist/decorators/autocomplete.decorator.d.ts +7 -3
- package/dist/decorators/autocomplete.decorator.js +7 -7
- package/dist/decorators/components.decorator.d.ts +4 -2
- package/dist/decorators/components.decorator.js +20 -8
- package/dist/decorators/context-menus.decorator.d.ts +2 -0
- package/dist/decorators/context-menus.decorator.js +14 -0
- package/dist/decorators/guilds.decorator.d.ts +1 -2
- package/dist/decorators/guilds.decorator.js +7 -7
- package/dist/decorators/index.d.ts +11 -8
- package/dist/decorators/index.js +27 -20
- package/dist/decorators/listeners.decorator.d.ts +5 -3
- package/dist/decorators/listeners.decorator.js +12 -13
- package/dist/decorators/modal.decorator.d.ts +2 -0
- package/dist/decorators/modal.decorator.js +16 -0
- package/dist/decorators/options.decorator.d.ts +111 -65
- package/dist/decorators/options.decorator.js +31 -22
- package/dist/decorators/{params.util.d.ts → param.utils.d.ts} +4 -4
- package/dist/decorators/{params.util.js → param.utils.js} +24 -24
- package/dist/decorators/params.decorator.d.ts +6 -5
- package/dist/decorators/params.decorator.js +30 -17
- package/dist/decorators/permissions.decorator.d.ts +5 -6
- package/dist/decorators/permissions.decorator.js +11 -17
- package/dist/decorators/slash-commands.decorator.d.ts +2 -0
- package/dist/decorators/slash-commands.decorator.js +24 -0
- package/dist/decorators/text-command.decorator.d.ts +1 -0
- package/dist/decorators/text-command.decorator.js +10 -0
- package/dist/discovery/component.discovery.d.ts +15 -0
- package/dist/discovery/component.discovery.js +33 -0
- package/dist/discovery/context-menu.discovery.d.ts +15 -0
- package/dist/discovery/context-menu.discovery.js +55 -0
- package/dist/discovery/index.d.ts +7 -0
- package/dist/discovery/index.js +23 -0
- package/dist/discovery/listener.discovery.d.ts +13 -0
- package/dist/discovery/listener.discovery.js +30 -0
- package/dist/discovery/mixins/base.discovery.d.ts +25 -0
- package/dist/discovery/mixins/base.discovery.js +37 -0
- package/dist/discovery/mixins/class-discovery.mixin.d.ts +7 -0
- package/dist/discovery/mixins/class-discovery.mixin.js +12 -0
- package/dist/discovery/mixins/command.discovery.d.ts +7 -0
- package/dist/discovery/mixins/command.discovery.js +7 -0
- package/dist/discovery/mixins/index.d.ts +4 -0
- package/dist/discovery/mixins/index.js +20 -0
- package/dist/discovery/mixins/method-discovery.mixin.d.ts +11 -0
- package/dist/discovery/mixins/method-discovery.mixin.js +25 -0
- package/dist/discovery/modal.discovery.d.ts +13 -0
- package/dist/discovery/modal.discovery.js +30 -0
- package/dist/discovery/slash-command.discovery.d.ts +46 -0
- package/dist/discovery/slash-command.discovery.js +103 -0
- package/dist/discovery/text-command.discovery.d.ts +13 -0
- package/dist/discovery/text-command.discovery.js +30 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +24 -18
- package/dist/interfaces/{necord-events.interface.d.ts → context.interface.d.ts} +98 -88
- package/dist/interfaces/{necord-events.interface.js → context.interface.js} +2 -2
- package/dist/interfaces/index.d.ts +4 -3
- package/dist/interfaces/index.js +20 -15
- package/dist/interfaces/{necord-options.interface.d.ts → module-options.interface.d.ts} +17 -16
- package/dist/interfaces/{necord-metadata.interface.js → module-options.interface.js} +2 -2
- package/dist/interfaces/non-empty-array.interface.d.ts +1 -0
- package/dist/interfaces/{necord-options.interface.js → non-empty-array.interface.js} +2 -2
- package/dist/interfaces/options.interface.d.ts +20 -0
- package/dist/interfaces/options.interface.js +2 -0
- package/dist/necord.constants.d.ts +13 -11
- package/dist/necord.constants.js +16 -15
- package/dist/necord.module.d.ts +14 -18
- package/dist/necord.module.js +115 -123
- package/dist/providers/client.provider.d.ts +3 -0
- package/dist/providers/client.provider.js +10 -0
- package/dist/providers/context-menus.provider.d.ts +6 -0
- package/dist/providers/context-menus.provider.js +9 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/{exceptions → providers}/index.js +19 -13
- package/dist/providers/slash-commands.provider.d.ts +6 -0
- package/dist/providers/slash-commands.provider.js +9 -0
- package/dist/services/autocomplete.service.d.ts +12 -0
- package/dist/services/autocomplete.service.js +69 -0
- package/dist/services/commands.service.d.ts +14 -0
- package/dist/services/commands.service.js +76 -0
- package/dist/services/components.service.d.ts +11 -0
- package/dist/services/components.service.js +42 -0
- package/dist/services/context-menus.service.d.ts +13 -0
- package/dist/services/context-menus.service.js +51 -0
- package/dist/services/explorer.service.d.ts +9 -0
- package/dist/services/explorer.service.js +31 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.js +25 -0
- package/dist/services/listeners.service.d.ts +21 -0
- package/dist/{necord.update.js → services/listeners.service.js} +239 -327
- package/dist/services/modals.service.d.ts +11 -0
- package/dist/services/modals.service.js +41 -0
- package/dist/services/slash-commands.service.d.ts +13 -0
- package/dist/services/slash-commands.service.js +83 -0
- package/dist/services/text-commands.service.d.ts +13 -0
- package/dist/services/text-commands.service.js +65 -0
- package/dist/services/tree.service.d.ts +19 -0
- package/dist/services/tree.service.js +93 -0
- package/package.json +23 -18
- package/dist/context/necord-info-type.enum.d.ts +0 -7
- package/dist/context/necord-info-type.enum.js +0 -11
- package/dist/decorators/commands.decorator.d.ts +0 -5
- package/dist/decorators/commands.decorator.js +0 -36
- package/dist/exceptions/index.d.ts +0 -1
- package/dist/exceptions/necord.exception.d.ts +0 -2
- package/dist/exceptions/necord.exception.js +0 -6
- package/dist/interfaces/necord-metadata.interface.d.ts +0 -38
- package/dist/necord-explorer.d.ts +0 -29
- package/dist/necord-explorer.js +0 -121
- package/dist/necord-interaction.update.d.ts +0 -11
- package/dist/necord-interaction.update.js +0 -158
- package/dist/necord-registry.d.ts +0 -24
- package/dist/necord-registry.js +0 -79
- package/dist/necord.update.d.ts +0 -21
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Whenever you need to handle any event data, use the `Context` decorator.
|
|
|
91
91
|
|
|
92
92
|
If you want to fully dive into Necord check out these resources:
|
|
93
93
|
|
|
94
|
-
* [Necord Wiki](https://
|
|
94
|
+
* [Necord Wiki](https://necord.org) - Official documentation of Necord.
|
|
95
95
|
* [Nest JS](https://docs.nestjs.com) - A progressive framework for creating well-architectured applications.
|
|
96
96
|
* [Discord JS](https://discord.js.org) - The most powerful library for creating bots.
|
|
97
97
|
* [Discord API](https://discord.com/developers/docs) - Official documentation of Discord API.
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './necord-arguments-host';
|
|
2
|
-
export * from './necord-
|
|
3
|
-
export * from './necord-
|
|
4
|
-
export * from './necord-params.factory';
|
|
1
|
+
export * from './necord-arguments-host';
|
|
2
|
+
export * from './necord-context-creator';
|
|
3
|
+
export * from './necord-execution-context';
|
|
4
|
+
export * from './necord-params.factory';
|
package/dist/context/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__exportStar(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./necord-arguments-host"), exports);
|
|
18
|
+
__exportStar(require("./necord-context-creator"), exports);
|
|
19
|
+
__exportStar(require("./necord-execution-context"), exports);
|
|
20
|
+
__exportStar(require("./necord-params.factory"), exports);
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
|
|
2
|
-
import { ArgumentsHost } from '@nestjs/common';
|
|
3
|
-
import { NecordContextType } from './necord-execution-context';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
|
|
2
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
3
|
+
import { NecordContextType } from './necord-execution-context';
|
|
4
|
+
import { ClientEvents } from 'discord.js';
|
|
5
|
+
import { BaseDiscovery } from '../discovery/mixins';
|
|
6
|
+
import { ContextOf } from '../interfaces';
|
|
7
|
+
export interface INecordArgumentsHost extends ArgumentsHost {
|
|
8
|
+
getContext<T extends keyof ClientEvents>(): ContextOf<T>;
|
|
9
|
+
getOptions<T = any>(): T;
|
|
10
|
+
getDiscovery(): BaseDiscovery;
|
|
11
|
+
getLocals<T extends Record<string, any>>(): T;
|
|
12
|
+
}
|
|
13
|
+
export declare class NecordArgumentsHost extends ExecutionContextHost implements INecordArgumentsHost {
|
|
14
|
+
static create(context: ArgumentsHost): NecordArgumentsHost;
|
|
15
|
+
getType<TContext extends string = NecordContextType>(): TContext;
|
|
16
|
+
getContext<T extends keyof ClientEvents>(): ContextOf<T>;
|
|
17
|
+
getOptions<T = any>(): T;
|
|
18
|
+
getDiscovery(): BaseDiscovery;
|
|
19
|
+
getLocals<T extends Record<string, any>>(): T;
|
|
20
|
+
}
|
|
@@ -1,25 +1,28 @@
|
|
|
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
|
-
getOptions() {
|
|
19
|
-
return this.getArgByIndex(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return this.getArgByIndex(2);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
getOptions() {
|
|
19
|
+
return this.getArgByIndex(1);
|
|
20
|
+
}
|
|
21
|
+
getDiscovery() {
|
|
22
|
+
return this.getArgByIndex(2);
|
|
23
|
+
}
|
|
24
|
+
getLocals() {
|
|
25
|
+
return this.getArgByIndex(3);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.NecordArgumentsHost = NecordArgumentsHost;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
|
|
3
|
+
export declare let createNecordContext: <T extends Record<string, any>>(instance: T, prototype: any, methodName: string) => (...args: any[]) => void;
|
|
4
|
+
export declare class NecordContextCreator implements OnModuleInit {
|
|
5
|
+
private readonly externalContextCreator;
|
|
6
|
+
private readonly necordParamsFactory;
|
|
7
|
+
constructor(externalContextCreator: ExternalContextCreator);
|
|
8
|
+
onModuleInit(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NecordContextCreator = exports.createNecordContext = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const external_context_creator_1 = require("@nestjs/core/helpers/external-context-creator");
|
|
15
|
+
const constants_1 = require("@nestjs/core/injector/constants");
|
|
16
|
+
const necord_params_factory_1 = require("./necord-params.factory");
|
|
17
|
+
const constants_2 = require("@nestjs/common/constants");
|
|
18
|
+
let NecordContextCreator = class NecordContextCreator {
|
|
19
|
+
constructor(externalContextCreator) {
|
|
20
|
+
this.externalContextCreator = externalContextCreator;
|
|
21
|
+
this.necordParamsFactory = new necord_params_factory_1.NecordParamsFactory();
|
|
22
|
+
}
|
|
23
|
+
onModuleInit() {
|
|
24
|
+
exports.createNecordContext = (instance, prototype, methodName) => {
|
|
25
|
+
return this.externalContextCreator.create(instance, prototype[methodName], methodName, constants_2.ROUTE_ARGS_METADATA, this.necordParamsFactory, constants_1.STATIC_CONTEXT, undefined, { guards: true, filters: true, interceptors: true }, 'necord');
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
NecordContextCreator = __decorate([
|
|
30
|
+
(0, common_1.Injectable)(),
|
|
31
|
+
__metadata("design:paramtypes", [external_context_creator_1.ExternalContextCreator])
|
|
32
|
+
], NecordContextCreator);
|
|
33
|
+
exports.NecordContextCreator = NecordContextCreator;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
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
|
-
}
|
|
13
|
-
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
|
+
}
|
|
13
|
+
exports.NecordExecutionContext = NecordExecutionContext;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ParamData } from '@nestjs/common';
|
|
2
|
-
import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
|
|
3
|
-
export declare enum NecordParamType {
|
|
4
|
-
CONTEXT = 0,
|
|
5
|
-
OPTIONS = 1,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { ParamData } from '@nestjs/common';
|
|
2
|
+
import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
|
|
3
|
+
export declare enum NecordParamType {
|
|
4
|
+
CONTEXT = 0,
|
|
5
|
+
OPTIONS = 1,
|
|
6
|
+
DISCOVERY = 2,
|
|
7
|
+
LOCALS = 3
|
|
8
|
+
}
|
|
9
|
+
export declare class NecordParamsFactory implements ParamsFactory {
|
|
10
|
+
exchangeKeyForValue(type: number, data: ParamData, args: unknown): any;
|
|
11
|
+
}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NecordParamsFactory = exports.NecordParamType = void 0;
|
|
4
|
-
var NecordParamType;
|
|
5
|
-
(function (NecordParamType) {
|
|
6
|
-
NecordParamType[NecordParamType["CONTEXT"] = 0] = "CONTEXT";
|
|
7
|
-
NecordParamType[NecordParamType["OPTIONS"] = 1] = "OPTIONS";
|
|
8
|
-
NecordParamType[NecordParamType["
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NecordParamsFactory = exports.NecordParamType = void 0;
|
|
4
|
+
var NecordParamType;
|
|
5
|
+
(function (NecordParamType) {
|
|
6
|
+
NecordParamType[NecordParamType["CONTEXT"] = 0] = "CONTEXT";
|
|
7
|
+
NecordParamType[NecordParamType["OPTIONS"] = 1] = "OPTIONS";
|
|
8
|
+
NecordParamType[NecordParamType["DISCOVERY"] = 2] = "DISCOVERY";
|
|
9
|
+
NecordParamType[NecordParamType["LOCALS"] = 3] = "LOCALS";
|
|
10
|
+
})(NecordParamType = exports.NecordParamType || (exports.NecordParamType = {}));
|
|
11
|
+
class NecordParamsFactory {
|
|
12
|
+
exchangeKeyForValue(type, data, args) {
|
|
13
|
+
if (!args)
|
|
14
|
+
return null;
|
|
15
|
+
switch (type) {
|
|
16
|
+
case NecordParamType.CONTEXT:
|
|
17
|
+
return args[0];
|
|
18
|
+
case NecordParamType.OPTIONS:
|
|
19
|
+
return data && args[1] ? args[1][data] : args[1];
|
|
20
|
+
case NecordParamType.DISCOVERY:
|
|
21
|
+
return args[2];
|
|
22
|
+
case NecordParamType.LOCALS:
|
|
23
|
+
return data ? args[3][data] : args[3];
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.NecordParamsFactory = NecordParamsFactory;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { ApplicationCommandOptionChoiceData, AutocompleteInteraction } from 'discord.js';
|
|
3
|
+
export interface TransformOptions {
|
|
4
|
+
transformOptions(interaction: AutocompleteInteraction, focused: ApplicationCommandOptionChoiceData): ApplicationCommandOptionChoiceData[] | Promise<ApplicationCommandOptionChoiceData[]>;
|
|
5
|
+
}
|
|
6
|
+
export declare type AutocompleteMeta = Type<TransformOptions>[];
|
|
7
|
+
export declare const Autocomplete: (...autocompletes: AutocompleteMeta) => MethodDecorator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Autocomplete = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const necord_constants_1 = require("../necord.constants");
|
|
6
|
-
const Autocomplete = (...autocompletes) => (0, common_1.SetMetadata)(necord_constants_1.AUTOCOMPLETE_METADATA, autocompletes);
|
|
7
|
-
exports.Autocomplete = Autocomplete;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Autocomplete = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const Autocomplete = (...autocompletes) => (0, common_1.SetMetadata)(necord_constants_1.AUTOCOMPLETE_METADATA, autocompletes);
|
|
7
|
+
exports.Autocomplete = Autocomplete;
|
|
@@ -1,2 +1,4 @@
|
|
|
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;
|
|
3
|
+
export declare const Component: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
4
|
+
export declare const Values: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectMenu = exports.Button = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const necord_constants_1 = require("../necord.constants");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Values = exports.Component = exports.SelectMenu = exports.Button = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const context_1 = require("../context");
|
|
7
|
+
const discord_js_1 = require("discord.js");
|
|
8
|
+
const createNecordComponentDecorator = (type) => (customId) => (0, common_1.SetMetadata)(necord_constants_1.MESSAGE_COMPONENT_METADATA, { type, customId });
|
|
9
|
+
exports.Button = createNecordComponentDecorator(discord_js_1.ComponentType.Button);
|
|
10
|
+
exports.SelectMenu = createNecordComponentDecorator(discord_js_1.ComponentType.SelectMenu);
|
|
11
|
+
exports.Component = (0, common_1.createParamDecorator)((_, ctx) => {
|
|
12
|
+
const necordContext = context_1.NecordExecutionContext.create(ctx);
|
|
13
|
+
const [interaction] = necordContext.getContext();
|
|
14
|
+
return interaction.isMessageComponent() ? interaction.component : null;
|
|
15
|
+
});
|
|
16
|
+
exports.Values = (0, common_1.createParamDecorator)((_, ctx) => {
|
|
17
|
+
const necordContext = context_1.NecordExecutionContext.create(ctx);
|
|
18
|
+
const [interaction] = necordContext.getContext();
|
|
19
|
+
return interaction.isSelectMenu() ? interaction.values : [];
|
|
20
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommand = exports.UserCommand = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const discord_js_1 = require("discord.js");
|
|
7
|
+
exports.UserCommand = createNecordContextMenu(discord_js_1.ApplicationCommandType.User);
|
|
8
|
+
exports.MessageCommand = createNecordContextMenu(discord_js_1.ApplicationCommandType.Message);
|
|
9
|
+
function createNecordContextMenu(type) {
|
|
10
|
+
return (name) => (0, common_1.SetMetadata)(necord_constants_1.CONTEXT_MENU_METADATA, {
|
|
11
|
+
type,
|
|
12
|
+
name
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const Guilds: (guildIds: Snowflake[]) => ClassDecorator & MethodDecorator;
|
|
1
|
+
export declare const Guilds: (guildIds_0: string, ...guildIds_1: string[]) => ClassDecorator & MethodDecorator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Guilds = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const necord_constants_1 = require("../necord.constants");
|
|
6
|
-
const Guilds = (guildIds) => (0, common_1.SetMetadata)(necord_constants_1.GUILDS_METADATA, guildIds);
|
|
7
|
-
exports.Guilds = Guilds;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guilds = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const Guilds = (...guildIds) => (0, common_1.SetMetadata)(necord_constants_1.GUILDS_METADATA, guildIds);
|
|
7
|
+
exports.Guilds = Guilds;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
1
|
+
export * from './params.decorator';
|
|
2
|
+
export * from './components.decorator';
|
|
3
|
+
export * from './listeners.decorator';
|
|
4
|
+
export * from './text-command.decorator';
|
|
5
|
+
export * from './context-menus.decorator';
|
|
6
|
+
export * from './slash-commands.decorator';
|
|
7
|
+
export * from './modal.decorator';
|
|
8
|
+
export * from './autocomplete.decorator';
|
|
9
|
+
export * from './options.decorator';
|
|
10
|
+
export * from './guilds.decorator';
|
|
11
|
+
export * from './permissions.decorator';
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__exportStar(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__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
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./params.decorator"), exports);
|
|
18
|
+
__exportStar(require("./components.decorator"), exports);
|
|
19
|
+
__exportStar(require("./listeners.decorator"), exports);
|
|
20
|
+
__exportStar(require("./text-command.decorator"), exports);
|
|
21
|
+
__exportStar(require("./context-menus.decorator"), exports);
|
|
22
|
+
__exportStar(require("./slash-commands.decorator"), exports);
|
|
23
|
+
__exportStar(require("./modal.decorator"), exports);
|
|
24
|
+
__exportStar(require("./autocomplete.decorator"), exports);
|
|
25
|
+
__exportStar(require("./options.decorator"), exports);
|
|
26
|
+
__exportStar(require("./guilds.decorator"), exports);
|
|
27
|
+
__exportStar(require("./permissions.decorator"), exports);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import { ListenerMeta } from '../discovery';
|
|
2
|
+
import { NecordEvents } from '../interfaces';
|
|
3
|
+
export declare const createNecordListenerDecorator: <K extends keyof E, E = NecordEvents>(type: ListenerMeta['type']) => (event: K) => MethodDecorator;
|
|
4
|
+
export declare const On: (event: keyof NecordEvents) => MethodDecorator;
|
|
5
|
+
export declare const Once: (event: keyof NecordEvents) => MethodDecorator;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Once = exports.On = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const necord_constants_1 = require("../necord.constants");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Once = exports.On = exports.createNecordListenerDecorator = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const createNecordListenerDecorator = (type) => (event) => (0, common_1.SetMetadata)(necord_constants_1.LISTENERS_METADATA, {
|
|
7
|
+
type,
|
|
8
|
+
event
|
|
9
|
+
});
|
|
10
|
+
exports.createNecordListenerDecorator = createNecordListenerDecorator;
|
|
11
|
+
exports.On = (0, exports.createNecordListenerDecorator)('on');
|
|
12
|
+
exports.Once = (0, exports.createNecordListenerDecorator)('once');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Fields = exports.Modal = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const necord_constants_1 = require("../necord.constants");
|
|
6
|
+
const context_1 = require("../context");
|
|
7
|
+
const Modal = (customId) => (0, common_1.SetMetadata)(necord_constants_1.MODAL_METADATA, { customId });
|
|
8
|
+
exports.Modal = Modal;
|
|
9
|
+
exports.Fields = (0, common_1.createParamDecorator)((customId, context) => {
|
|
10
|
+
const necordContext = context_1.NecordExecutionContext.create(context);
|
|
11
|
+
const [interaction] = necordContext.getContext();
|
|
12
|
+
if (!interaction.isModalSubmit()) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return customId ? interaction.fields.getTextInputValue(customId) : interaction.fields;
|
|
16
|
+
});
|