necord 3.0.5 → 3.0.8
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.
|
@@ -59,15 +59,15 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
59
59
|
prototype,
|
|
60
60
|
method });
|
|
61
61
|
});
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
for (let _a of commands) {
|
|
63
|
+
const { instance, prototype, method } = _a, command = __rest(_a, ["instance", "prototype", "method"]);
|
|
64
64
|
const options = this.metadataAccessor.getOptionsMetadata(instance, method);
|
|
65
65
|
let group = this.metadataAccessor.getCommandGroupMetadata(instance, method);
|
|
66
66
|
let subGroup = this.metadataAccessor.getCommandSubGroupMetadata(instance, method);
|
|
67
67
|
if (command.type !== 1 /* CHAT_INPUT */) {
|
|
68
68
|
this.commands.push(command);
|
|
69
69
|
this.registerContextMenuHandler(command, command.execute);
|
|
70
|
-
|
|
70
|
+
continue;
|
|
71
71
|
}
|
|
72
72
|
else if (!group && subGroup) {
|
|
73
73
|
subGroup = undefined;
|
|
@@ -76,13 +76,12 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
76
76
|
this.registerSlashCommandHandler(group === null || group === void 0 ? void 0 : group.name, subGroup === null || subGroup === void 0 ? void 0 : subGroup.name, command, options, command.execute);
|
|
77
77
|
if (!group && !subGroup) {
|
|
78
78
|
this.commands.push(command);
|
|
79
|
-
|
|
79
|
+
continue;
|
|
80
80
|
}
|
|
81
81
|
const cachedGroup = this.commands.find(c => c.type === 1 /* CHAT_INPUT */ && c.name === group.name);
|
|
82
82
|
group = cachedGroup !== null && cachedGroup !== void 0 ? cachedGroup : group;
|
|
83
83
|
if (!subGroup) {
|
|
84
84
|
group.options.push(command);
|
|
85
|
-
return;
|
|
86
85
|
}
|
|
87
86
|
else {
|
|
88
87
|
const cachedSubGroup = group.options.find(s => s.type === 2 /* SUB_COMMAND_GROUP */ && s.name === (subGroup === null || subGroup === void 0 ? void 0 : subGroup.name));
|
|
@@ -91,7 +90,7 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
91
90
|
!cachedSubGroup && group.options.push(subGroup);
|
|
92
91
|
}
|
|
93
92
|
!cachedGroup && this.commands.push(group);
|
|
94
|
-
}
|
|
93
|
+
}
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
96
|
onReadyRegistration() {
|
|
@@ -9,5 +9,5 @@ export declare class ComponentsService implements OnModuleInit {
|
|
|
9
9
|
private readonly client;
|
|
10
10
|
private readonly components;
|
|
11
11
|
constructor(explorerService: ExplorerService<ComponentMetadata>, metadataAccessor: MetadataAccessorService, client: Client);
|
|
12
|
-
onModuleInit(): void
|
|
12
|
+
onModuleInit(): Promise<void>;
|
|
13
13
|
}
|
|
@@ -8,6 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
11
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
21
|
exports.ComponentsService = void 0;
|
|
13
22
|
const explorer_service_1 = require("./explorer.service");
|
|
@@ -22,13 +31,15 @@ let ComponentsService = class ComponentsService {
|
|
|
22
31
|
this.components = new Map();
|
|
23
32
|
}
|
|
24
33
|
onModuleInit() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const components = this.explorerService.explore((instance, prototype, method) => this.metadataAccessor.getMessageComponentMetadata(instance, method));
|
|
36
|
+
for (const component of components) {
|
|
37
|
+
this.client.on('interactionCreate', interaction => interaction.isMessageComponent() &&
|
|
38
|
+
interaction.componentType === discord_js_1.MessageComponentInteraction.resolveType(component.type) &&
|
|
39
|
+
interaction.customId === component.customId &&
|
|
40
|
+
component.execute(interaction));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
32
43
|
}
|
|
33
44
|
};
|
|
34
45
|
ComponentsService = __decorate([
|
|
@@ -33,7 +33,7 @@ let ListenersService = class ListenersService {
|
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const listeners = this.explorerService.explore((instance, prototype, name) => this.metadataAccessor.getListenerMetadata(instance, name));
|
|
35
35
|
for (const listener of listeners) {
|
|
36
|
-
this.client[listener.type](listener.event, (...args) => listener.execute(args));
|
|
36
|
+
this.client[listener.type](listener.event, (...args) => listener.execute(args.length > 1 ? args : args[0]));
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "necord",
|
|
3
3
|
"description": "A module for creating Discord bots using NestJS, based on Discord.js.",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.8",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf -rf dist && tsc -p tsconfig.json",
|
|
7
7
|
"prepublish:npm": "npm run build",
|
|
8
|
-
"publish:npm": "
|
|
8
|
+
"publish:npm": "release-it",
|
|
9
9
|
"prepublish:dev": "npm run build",
|
|
10
10
|
"publish:dev": "npm publish --access public --tag dev",
|
|
11
11
|
"prepare": "husky install .github/husky",
|
|
12
12
|
"test": "echo add tests",
|
|
13
13
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
14
|
-
"lint": "eslint --ignore-path .gitignore {integration,src}/**/*.ts"
|
|
15
|
-
"release": "release-it"
|
|
14
|
+
"lint": "eslint --ignore-path .gitignore {integration,src}/**/*.ts"
|
|
16
15
|
},
|
|
17
16
|
"main": "./dist/index.js",
|
|
18
17
|
"types": "./dist/index.d.ts",
|
|
@@ -43,15 +42,15 @@
|
|
|
43
42
|
],
|
|
44
43
|
"dependencies": {},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@commitlint/cli": "
|
|
47
|
-
"@commitlint/config-angular": "
|
|
48
|
-
"@favware/npm-deprecate": "
|
|
45
|
+
"@commitlint/cli": "16.0.0",
|
|
46
|
+
"@commitlint/config-angular": "16.0.0",
|
|
47
|
+
"@favware/npm-deprecate": "1.0.4",
|
|
49
48
|
"@nestjs/common": "8.2.4",
|
|
50
49
|
"@nestjs/core": "8.2.4",
|
|
51
|
-
"@types/node": "17.0.
|
|
50
|
+
"@types/node": "17.0.5",
|
|
52
51
|
"@typescript-eslint/eslint-plugin": "4.33.0",
|
|
53
52
|
"@typescript-eslint/parser": "4.33.0",
|
|
54
|
-
"discord.js": "13.
|
|
53
|
+
"discord.js": "13.3.1",
|
|
55
54
|
"eslint": "7.32.0",
|
|
56
55
|
"eslint-config-prettier": "8.3.0",
|
|
57
56
|
"eslint-plugin-prettier": "4.0.0",
|