@pikokr/command.ts 3.2.4-dev.434c22e → 4.0.0-dev.7a5eecc
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/index.d.ts +310 -9
- package/dist/index.js +1 -21
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/publish-version.js +7 -3
- package/src/applicationCommand/AppCommand.ts +32 -0
- package/src/{slashCommand → applicationCommand}/decorator.ts +14 -10
- package/src/applicationCommand/index.ts +6 -0
- package/src/builtinModules/BuiltInModule.ts +4 -0
- package/src/builtinModules/BuiltinApplicationCommandConverters.ts +16 -0
- package/src/builtinModules/BuiltinCommandConverters.ts +4 -0
- package/src/builtinModules/CommandHandler.ts +172 -20
- package/src/builtinModules/index.ts +5 -1
- package/src/command/ArgumentConverter.ts +7 -3
- package/src/command/Command.ts +6 -2
- package/src/command/cooldown/adapter.ts +4 -0
- package/src/command/cooldown/decorator.ts +4 -0
- package/src/command/cooldown/error.ts +4 -0
- package/src/command/cooldown/index.ts +4 -0
- package/src/command/cooldown/type.ts +4 -0
- package/src/command/decorator.ts +10 -5
- package/src/command/index.ts +4 -0
- package/src/command/utils.ts +13 -9
- package/src/constants.ts +8 -2
- package/src/error/ArgumentConverterNotFound.ts +8 -4
- package/src/error/ArgumentNotProvided.ts +4 -0
- package/src/error/CommandCheckFailed.ts +8 -4
- package/src/error/CommandNotFound.ts +4 -0
- package/src/error/InvalidTargetError.ts +4 -0
- package/src/error/ModuleError.ts +4 -0
- package/src/error/PermissionRequired.ts +4 -0
- package/src/error/checks/DMOnlyCommand.ts +4 -0
- package/src/error/checks/GuildOnlyCommand.ts +4 -0
- package/src/error/checks/OwnerOnlyCommand.ts +4 -0
- package/src/error/checks/SlashCommandGlobalCheckError.ts +11 -0
- package/src/error/checks/index.ts +4 -0
- package/src/error/index.ts +4 -0
- package/src/index.ts +6 -1
- package/src/interface/index.ts +4 -0
- package/src/listener/Listener.ts +4 -0
- package/src/listener/decorator.ts +4 -0
- package/src/listener/index.ts +4 -0
- package/src/messageComponents/base.ts +16 -0
- package/src/messageComponents/button.ts +30 -0
- package/src/messageComponents/index.ts +6 -0
- package/src/messageComponents/selectMenu.ts +30 -0
- package/src/structures/CommandClient.ts +20 -10
- package/src/structures/Module.ts +15 -6
- package/src/structures/Registry.ts +29 -19
- package/src/structures/index.ts +4 -0
- package/src/typings.ts +18 -2
- package/src/utils.ts +4 -0
- package/test/index.ts +6 -2
- package/test/modules/dev.ts +13 -5
- package/test/modules/test.ts +92 -15
- package/tsup.config.ts +14 -0
- package/dist/builtinModules/BuiltInModule.d.ts +0 -4
- package/dist/builtinModules/BuiltInModule.js +0 -13
- package/dist/builtinModules/BuiltInModule.js.map +0 -1
- package/dist/builtinModules/BuiltinCommandConverters.d.ts +0 -16
- package/dist/builtinModules/BuiltinCommandConverters.js +0 -127
- package/dist/builtinModules/BuiltinCommandConverters.js.map +0 -1
- package/dist/builtinModules/BuiltinSlashCommandConverters.d.ts +0 -10
- package/dist/builtinModules/BuiltinSlashCommandConverters.js +0 -42
- package/dist/builtinModules/BuiltinSlashCommandConverters.js.map +0 -1
- package/dist/builtinModules/CommandHandler.d.ts +0 -11
- package/dist/builtinModules/CommandHandler.js +0 -233
- package/dist/builtinModules/CommandHandler.js.map +0 -1
- package/dist/builtinModules/index.d.ts +0 -3
- package/dist/builtinModules/index.js +0 -16
- package/dist/builtinModules/index.js.map +0 -1
- package/dist/command/ArgumentConverter.d.ts +0 -15
- package/dist/command/ArgumentConverter.js +0 -25
- package/dist/command/ArgumentConverter.js.map +0 -1
- package/dist/command/Command.d.ts +0 -20
- package/dist/command/Command.js +0 -22
- package/dist/command/Command.js.map +0 -1
- package/dist/command/cooldown/adapter.d.ts +0 -10
- package/dist/command/cooldown/adapter.js +0 -31
- package/dist/command/cooldown/adapter.js.map +0 -1
- package/dist/command/cooldown/decorator.d.ts +0 -2
- package/dist/command/cooldown/decorator.js +0 -73
- package/dist/command/cooldown/decorator.js.map +0 -1
- package/dist/command/cooldown/error.d.ts +0 -4
- package/dist/command/cooldown/error.js +0 -11
- package/dist/command/cooldown/error.js.map +0 -1
- package/dist/command/cooldown/index.d.ts +0 -5
- package/dist/command/cooldown/index.js +0 -18
- package/dist/command/cooldown/index.js.map +0 -1
- package/dist/command/cooldown/type.d.ts +0 -8
- package/dist/command/cooldown/type.js +0 -13
- package/dist/command/cooldown/type.js.map +0 -1
- package/dist/command/decorator.d.ts +0 -16
- package/dist/command/decorator.js +0 -137
- package/dist/command/decorator.js.map +0 -1
- package/dist/command/index.d.ts +0 -5
- package/dist/command/index.js +0 -18
- package/dist/command/index.js.map +0 -1
- package/dist/command/utils.d.ts +0 -2
- package/dist/command/utils.js +0 -30
- package/dist/command/utils.js.map +0 -1
- package/dist/constants.d.ts +0 -13
- package/dist/constants.js +0 -17
- package/dist/constants.js.map +0 -1
- package/dist/error/ArgumentConverterNotFound.d.ts +0 -13
- package/dist/error/ArgumentConverterNotFound.js +0 -20
- package/dist/error/ArgumentConverterNotFound.js.map +0 -1
- package/dist/error/ArgumentNotProvided.d.ts +0 -8
- package/dist/error/ArgumentNotProvided.js +0 -13
- package/dist/error/ArgumentNotProvided.js.map +0 -1
- package/dist/error/CommandCheckFailed.d.ts +0 -13
- package/dist/error/CommandCheckFailed.js +0 -20
- package/dist/error/CommandCheckFailed.js.map +0 -1
- package/dist/error/CommandNotFound.d.ts +0 -7
- package/dist/error/CommandNotFound.js +0 -13
- package/dist/error/CommandNotFound.js.map +0 -1
- package/dist/error/InvalidTargetError.d.ts +0 -3
- package/dist/error/InvalidTargetError.js +0 -10
- package/dist/error/InvalidTargetError.js.map +0 -1
- package/dist/error/ModuleError.d.ts +0 -6
- package/dist/error/ModuleError.js +0 -14
- package/dist/error/ModuleError.js.map +0 -1
- package/dist/error/PermissionRequired.d.ts +0 -10
- package/dist/error/PermissionRequired.js +0 -19
- package/dist/error/PermissionRequired.js.map +0 -1
- package/dist/error/checks/DMOnlyCommand.d.ts +0 -3
- package/dist/error/checks/DMOnlyCommand.js +0 -10
- package/dist/error/checks/DMOnlyCommand.js.map +0 -1
- package/dist/error/checks/GuildOnlyCommand.d.ts +0 -3
- package/dist/error/checks/GuildOnlyCommand.js +0 -10
- package/dist/error/checks/GuildOnlyCommand.js.map +0 -1
- package/dist/error/checks/OwnerOnlyCommand.d.ts +0 -3
- package/dist/error/checks/OwnerOnlyCommand.js +0 -10
- package/dist/error/checks/OwnerOnlyCommand.js.map +0 -1
- package/dist/error/checks/index.d.ts +0 -3
- package/dist/error/checks/index.js +0 -16
- package/dist/error/checks/index.js.map +0 -1
- package/dist/error/index.d.ts +0 -7
- package/dist/error/index.js +0 -20
- package/dist/error/index.js.map +0 -1
- package/dist/interface/index.d.ts +0 -1
- package/dist/interface/index.js +0 -4
- package/dist/interface/index.js.map +0 -1
- package/dist/listener/Listener.d.ts +0 -5
- package/dist/listener/Listener.js +0 -11
- package/dist/listener/Listener.js.map +0 -1
- package/dist/listener/decorator.d.ts +0 -2
- package/dist/listener/decorator.js +0 -22
- package/dist/listener/decorator.js.map +0 -1
- package/dist/listener/index.d.ts +0 -2
- package/dist/listener/index.js +0 -15
- package/dist/listener/index.js.map +0 -1
- package/dist/slashCommand/SlashCommand.d.ts +0 -19
- package/dist/slashCommand/SlashCommand.js +0 -22
- package/dist/slashCommand/SlashCommand.js.map +0 -1
- package/dist/slashCommand/decorator.d.ts +0 -10
- package/dist/slashCommand/decorator.js +0 -38
- package/dist/slashCommand/decorator.js.map +0 -1
- package/dist/slashCommand/index.d.ts +0 -2
- package/dist/slashCommand/index.js +0 -15
- package/dist/slashCommand/index.js.map +0 -1
- package/dist/structures/CommandClient.d.ts +0 -41
- package/dist/structures/CommandClient.js +0 -95
- package/dist/structures/CommandClient.js.map +0 -1
- package/dist/structures/Module.d.ts +0 -19
- package/dist/structures/Module.js +0 -35
- package/dist/structures/Module.js.map +0 -1
- package/dist/structures/Registry.d.ts +0 -28
- package/dist/structures/Registry.js +0 -223
- package/dist/structures/Registry.js.map +0 -1
- package/dist/structures/index.d.ts +0 -3
- package/dist/structures/index.js +0 -16
- package/dist/structures/index.js.map +0 -1
- package/dist/typings.d.ts +0 -18
- package/dist/typings.js +0 -3
- package/dist/typings.js.map +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -11
- package/dist/utils.js.map +0 -1
- package/src/builtinModules/BuiltinSlashCommandConverters.ts +0 -23
- package/src/slashCommand/SlashCommand.ts +0 -29
- package/src/slashCommand/index.ts +0 -2
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CommandClient = void 0;
|
|
27
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
28
|
-
const Registry_1 = require("./Registry");
|
|
29
|
-
const discord_js_1 = require("discord.js");
|
|
30
|
-
const builtinModules_1 = require("../builtinModules");
|
|
31
|
-
const command_1 = require("../command");
|
|
32
|
-
const rest_1 = require("@discordjs/rest");
|
|
33
|
-
const tslog_1 = require("tslog");
|
|
34
|
-
class CommandClient {
|
|
35
|
-
constructor(_a) {
|
|
36
|
-
var { client, coolDownAdapter, logger } = _a, options = __rest(_a, ["client", "coolDownAdapter", "logger"]);
|
|
37
|
-
this.owners = [];
|
|
38
|
-
this.registry = new Registry_1.Registry(this);
|
|
39
|
-
this.rest = new rest_1.REST({
|
|
40
|
-
version: '9',
|
|
41
|
-
});
|
|
42
|
-
this._isReady = false;
|
|
43
|
-
this.client = client;
|
|
44
|
-
this.coolDownAdapter = coolDownAdapter || new command_1.DefaultCoolDownAdapter();
|
|
45
|
-
this.options = lodash_1.default.merge({
|
|
46
|
-
command: {
|
|
47
|
-
prefix: '!',
|
|
48
|
-
check: () => true,
|
|
49
|
-
globalAliases: () => [],
|
|
50
|
-
},
|
|
51
|
-
owners: 'auto',
|
|
52
|
-
slashCommands: {
|
|
53
|
-
autoSync: true,
|
|
54
|
-
},
|
|
55
|
-
}, options);
|
|
56
|
-
this.logger = logger !== null && logger !== void 0 ? logger : new tslog_1.Logger({ name: 'Command.TS' });
|
|
57
|
-
if (this.options.owners !== 'auto') {
|
|
58
|
-
this.owners = this.options.owners;
|
|
59
|
-
}
|
|
60
|
-
this.client.once('ready', () => this.ready());
|
|
61
|
-
this.registry.registerModule(new builtinModules_1.CommandHandler(this.registry));
|
|
62
|
-
this.registry.registerModule(new builtinModules_1.BuiltinCommandConverters(this));
|
|
63
|
-
this.registry.registerModule(new builtinModules_1.BuiltinSlashCommandConverters(this));
|
|
64
|
-
}
|
|
65
|
-
fetchOwners() {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
yield ((_a = this.client.application) === null || _a === void 0 ? void 0 : _a.fetch());
|
|
69
|
-
const o = (_b = this.client.application) === null || _b === void 0 ? void 0 : _b.owner;
|
|
70
|
-
if (!o)
|
|
71
|
-
return [];
|
|
72
|
-
if (o instanceof discord_js_1.User)
|
|
73
|
-
return [o.id];
|
|
74
|
-
else
|
|
75
|
-
return o.members.map((x) => x.id);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
ready() {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
if (this._isReady)
|
|
81
|
-
return;
|
|
82
|
-
this.rest.setToken(this.client.token);
|
|
83
|
-
this._isReady = true;
|
|
84
|
-
if (this.options.owners === 'auto') {
|
|
85
|
-
const owners = yield this.fetchOwners();
|
|
86
|
-
this.owners.push(...owners);
|
|
87
|
-
}
|
|
88
|
-
if (this.options.slashCommands.autoSync) {
|
|
89
|
-
yield this.registry.syncCommands();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.CommandClient = CommandClient;
|
|
95
|
-
//# sourceMappingURL=CommandClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandClient.js","sourceRoot":"","sources":["../../src/structures/CommandClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,yCAAqC;AACrC,2CAA6D;AAC7D,sDAA2G;AAC3G,wCAAoE;AACpE,0CAAsC;AACtC,iCAA8B;AAyB9B,MAAa,aAAa;IAkCxB,YAAY,EAA4J;YAA5J,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAA2H,EAAtH,OAAO,cAA7C,uCAA+C,CAAF;QAhCzD,WAAM,GAAa,EAAE,CAAA;QACrB,aAAQ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M,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,WAAW,0CAAE,KAAK,EAAE,CAAA,CAAA;YACtC,MAAM,CAAC,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,WAAW,0CAAE,KAAK,CAAA;YACxC,IAAI,CAAC,CAAC;gBAAE,OAAO,EAAE,CAAA;YACjB,IAAI,CAAC,YAAY,iBAAI;gBAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;;gBAC/B,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;;KACvC;IAEK,KAAK;;YACT,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAM;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAM,CAAC,CAAA;YACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YACpB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;gBAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;gBACvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;aAC5B;YACD,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE;gBACvC,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAA;aACnC;QACH,CAAC;KAAA;CA+BF;AA/DD,sCA+DC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Command } from '../command';
|
|
2
|
-
import { Listener } from '../listener';
|
|
3
|
-
import { ArgumentConverter, SlashArgumentConverter } from '../command';
|
|
4
|
-
import { SlashCommand } from '../slashCommand';
|
|
5
|
-
import { CommandClient } from './CommandClient';
|
|
6
|
-
export declare abstract class Module {
|
|
7
|
-
commandClient: CommandClient;
|
|
8
|
-
get logger(): import("tslog").Logger;
|
|
9
|
-
get commands(): Command[];
|
|
10
|
-
get listeners(): Listener[];
|
|
11
|
-
get argumentConverters(): ArgumentConverter[];
|
|
12
|
-
get slashArgumentConverters(): SlashArgumentConverter[];
|
|
13
|
-
get slashCommands(): SlashCommand[];
|
|
14
|
-
get path(): string | undefined;
|
|
15
|
-
load(): void;
|
|
16
|
-
unload(): void;
|
|
17
|
-
beforeReload(): void;
|
|
18
|
-
afterReload(): void;
|
|
19
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Module = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
class Module {
|
|
6
|
-
get logger() {
|
|
7
|
-
return this.commandClient.logger.getChildLogger({
|
|
8
|
-
name: this.constructor.name,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
get commands() {
|
|
12
|
-
return Reflect.getMetadata(constants_1.KCommands, this) || [];
|
|
13
|
-
}
|
|
14
|
-
get listeners() {
|
|
15
|
-
return Reflect.getMetadata(constants_1.KListeners, this) || [];
|
|
16
|
-
}
|
|
17
|
-
get argumentConverters() {
|
|
18
|
-
return Reflect.getMetadata(constants_1.KArgumentConverters, this) || [];
|
|
19
|
-
}
|
|
20
|
-
get slashArgumentConverters() {
|
|
21
|
-
return Reflect.getMetadata(constants_1.KSlashArgumentConverters, this) || [];
|
|
22
|
-
}
|
|
23
|
-
get slashCommands() {
|
|
24
|
-
return Reflect.getMetadata(constants_1.KSlashCommands, this) || [];
|
|
25
|
-
}
|
|
26
|
-
get path() {
|
|
27
|
-
return Reflect.getMetadata(constants_1.KModulePath, this);
|
|
28
|
-
}
|
|
29
|
-
load() { }
|
|
30
|
-
unload() { }
|
|
31
|
-
beforeReload() { }
|
|
32
|
-
afterReload() { }
|
|
33
|
-
}
|
|
34
|
-
exports.Module = Module;
|
|
35
|
-
//# sourceMappingURL=Module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Module.js","sourceRoot":"","sources":["../../src/structures/Module.ts"],"names":[],"mappings":";;;AAAA,4CAAgI;AAOhI,MAAsB,MAAM;IAG1B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC;YAC9C,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;SAC5B,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,OAAO,CAAC,WAAW,CAAC,qBAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACnD,CAAC;IAED,IAAI,SAAS;QACX,OAAO,OAAO,CAAC,WAAW,CAAC,sBAAU,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACpD,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,OAAO,CAAC,WAAW,CAAC,+BAAmB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC7D,CAAC;IAED,IAAI,uBAAuB;QACzB,OAAO,OAAO,CAAC,WAAW,CAAC,oCAAwB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAClE,CAAC;IAED,IAAI,aAAa;QACf,OAAO,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACxD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,OAAO,CAAC,WAAW,CAAC,uBAAW,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;IAED,IAAI,KAAI,CAAC;IACT,MAAM,KAAI,CAAC;IACX,YAAY,KAAI,CAAC;IACjB,WAAW,KAAI,CAAC;CACjB;AArCD,wBAqCC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { CommandClient } from './CommandClient';
|
|
2
|
-
import { Module } from './Module';
|
|
3
|
-
import { Command, SlashArgumentConverter } from '../command';
|
|
4
|
-
import { Collection } from 'discord.js';
|
|
5
|
-
import { ArgumentConverter } from '../command';
|
|
6
|
-
import { SlashCommand } from '../slashCommand';
|
|
7
|
-
export declare class Registry {
|
|
8
|
-
client: CommandClient;
|
|
9
|
-
constructor(client: CommandClient);
|
|
10
|
-
modules: Collection<symbol, Module>;
|
|
11
|
-
private get logger();
|
|
12
|
-
get commands(): Command[];
|
|
13
|
-
get argumentConverters(): ArgumentConverter[];
|
|
14
|
-
get slashArgumentConverters(): SlashArgumentConverter[];
|
|
15
|
-
get slashCommands(): SlashCommand[];
|
|
16
|
-
registerModule(module: Module): Module;
|
|
17
|
-
loadModulesIn(dir: string, absolute?: boolean): Promise<void>;
|
|
18
|
-
loadModule(file: string, absolute?: boolean): Promise<Module>;
|
|
19
|
-
syncCommands(): Promise<void>;
|
|
20
|
-
unregisterModule(module: Module): Promise<Module>;
|
|
21
|
-
unloadModule(module: Module): Promise<void>;
|
|
22
|
-
reloadModule(module: Module): Promise<boolean>;
|
|
23
|
-
reloadAll(): Promise<{
|
|
24
|
-
path: string;
|
|
25
|
-
success: boolean;
|
|
26
|
-
error?: Error | undefined;
|
|
27
|
-
}[]>;
|
|
28
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.Registry = void 0;
|
|
35
|
-
const Module_1 = require("./Module");
|
|
36
|
-
const constants_1 = require("../constants");
|
|
37
|
-
const path_1 = __importDefault(require("path"));
|
|
38
|
-
const error_1 = require("../error");
|
|
39
|
-
const discord_js_1 = require("discord.js");
|
|
40
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
41
|
-
const v9_1 = require("discord-api-types/v9");
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
class Registry {
|
|
44
|
-
constructor(client) {
|
|
45
|
-
this.client = client;
|
|
46
|
-
this.modules = new discord_js_1.Collection();
|
|
47
|
-
}
|
|
48
|
-
get logger() {
|
|
49
|
-
return this.client.logger.getChildLogger({
|
|
50
|
-
name: 'Registry',
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
get commands() {
|
|
54
|
-
const result = [];
|
|
55
|
-
for (const [, module] of this.modules) {
|
|
56
|
-
result.push(...module.commands);
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
get argumentConverters() {
|
|
61
|
-
const result = [];
|
|
62
|
-
for (const [, module] of this.modules) {
|
|
63
|
-
result.push(...module.argumentConverters);
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
get slashArgumentConverters() {
|
|
68
|
-
const result = [];
|
|
69
|
-
for (const [, module] of this.modules) {
|
|
70
|
-
result.push(...module.slashArgumentConverters);
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
get slashCommands() {
|
|
75
|
-
const result = [];
|
|
76
|
-
for (const [, module] of this.modules) {
|
|
77
|
-
result.push(...module.slashCommands);
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
registerModule(module) {
|
|
82
|
-
module.commandClient = this.client;
|
|
83
|
-
this.modules.set(Symbol(module.constructor.name), module);
|
|
84
|
-
const list = [];
|
|
85
|
-
for (const listener of module.listeners) {
|
|
86
|
-
const bound = listener.execute.bind(module);
|
|
87
|
-
list.push({ event: listener.name, execute: bound });
|
|
88
|
-
this.client.client.on(listener.name, bound);
|
|
89
|
-
}
|
|
90
|
-
Reflect.defineMetadata(constants_1.KListenerExecuteCache, list, module);
|
|
91
|
-
return module;
|
|
92
|
-
}
|
|
93
|
-
loadModulesIn(dir, absolute = false) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
let p = absolute ? dir : path_1.default.join(require.main.path, dir);
|
|
96
|
-
for (const i of walk_sync_1.default(p)) {
|
|
97
|
-
if (fs.lstatSync(path_1.default.join(p, i)).isFile()) {
|
|
98
|
-
if (i.endsWith('.map'))
|
|
99
|
-
continue;
|
|
100
|
-
yield this.loadModule(path_1.default.join(p, i), true);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
loadModule(file, absolute = false) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
let p = absolute ? file : path_1.default.join(require.main.path, file);
|
|
108
|
-
let m;
|
|
109
|
-
try {
|
|
110
|
-
m = require(p);
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
throw new error_1.ModuleLoadError(p, e);
|
|
114
|
-
}
|
|
115
|
-
if (m.loaded)
|
|
116
|
-
throw new Error('MODULE_ALREADY_LOADED');
|
|
117
|
-
if (!m.install)
|
|
118
|
-
throw new error_1.InvalidModuleError('Install function not found.');
|
|
119
|
-
const mod = m.install(this.client);
|
|
120
|
-
if (!(mod instanceof Module_1.Module))
|
|
121
|
-
throw new error_1.InvalidTargetError();
|
|
122
|
-
Reflect.defineMetadata(constants_1.KModulePath, require.resolve(p), mod);
|
|
123
|
-
this.registerModule(mod);
|
|
124
|
-
yield mod.load();
|
|
125
|
-
m.loaded = true;
|
|
126
|
-
return mod;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
syncCommands() {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
this.logger.debug(`Syncing commands...`);
|
|
132
|
-
const commands = this.slashCommands.filter((x) => !x.guild);
|
|
133
|
-
const guild = this.client.options.slashCommands.guild;
|
|
134
|
-
if (guild) {
|
|
135
|
-
const syncForGuild = (g) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
this.logger.debug(`Syncing for guild ${g.name}(${g.id})`);
|
|
137
|
-
const commandsToRegister = [
|
|
138
|
-
...commands.map((x) => x.commandBuilder),
|
|
139
|
-
...this.slashCommands.filter((y) => { var _a; return y.guild === g.id || ((_a = y.guild) === null || _a === void 0 ? void 0 : _a.includes(g.id)) || false; }).map((x) => x.commandBuilder),
|
|
140
|
-
];
|
|
141
|
-
this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`);
|
|
142
|
-
yield this.client.rest.put(v9_1.Routes.applicationGuildCommands(this.client.client.application.id, g.id), {
|
|
143
|
-
body: commandsToRegister.map((x) => x.toJSON()),
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
if (typeof guild === 'string') {
|
|
147
|
-
yield syncForGuild(yield this.client.client.guilds.fetch(guild));
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
for (const g of guild) {
|
|
151
|
-
yield syncForGuild(yield this.client.client.guilds.fetch(g));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
this.logger.debug('Syncing global...');
|
|
157
|
-
yield this.client.rest.put(v9_1.Routes.applicationCommands(this.client.client.application.id), {
|
|
158
|
-
body: commands.map((x) => x.commandBuilder.toJSON()),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
this.logger.debug('Syncing ended.');
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
unregisterModule(module) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
if (Reflect.getMetadata(constants_1.KBuiltInModule, module))
|
|
167
|
-
throw new Error('Built-in modules cannot be unloaded');
|
|
168
|
-
const symbol = this.modules.findKey((x) => x === module);
|
|
169
|
-
if (!symbol)
|
|
170
|
-
return module;
|
|
171
|
-
yield module.unload();
|
|
172
|
-
const list = Reflect.getMetadata(constants_1.KListenerExecuteCache, module);
|
|
173
|
-
for (const listener of list) {
|
|
174
|
-
this.client.client.removeListener(listener.event, listener.execute);
|
|
175
|
-
}
|
|
176
|
-
this.modules.delete(symbol);
|
|
177
|
-
return module;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
unloadModule(module) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
const p = Reflect.getMetadata(constants_1.KModulePath, module);
|
|
183
|
-
if (!p)
|
|
184
|
-
throw new error_1.InvalidModuleError('This module is not loaded by loadModule.');
|
|
185
|
-
yield this.unregisterModule(module);
|
|
186
|
-
delete require.cache[p];
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
reloadModule(module) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
yield module.beforeReload();
|
|
192
|
-
const p = Reflect.getMetadata(constants_1.KModulePath, module);
|
|
193
|
-
yield this.unloadModule(module);
|
|
194
|
-
const mod = yield this.loadModule(p, true);
|
|
195
|
-
yield mod.afterReload();
|
|
196
|
-
return true;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
reloadAll() {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
const results = [];
|
|
202
|
-
for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(constants_1.KBuiltInModule, x))) {
|
|
203
|
-
try {
|
|
204
|
-
yield this.reloadModule(module);
|
|
205
|
-
results.push({
|
|
206
|
-
path: module.path,
|
|
207
|
-
success: true,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
catch (e) {
|
|
211
|
-
results.push({
|
|
212
|
-
error: e,
|
|
213
|
-
path: module.path,
|
|
214
|
-
success: false,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return results;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
exports.Registry = Registry;
|
|
223
|
-
//# sourceMappingURL=Registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Registry.js","sourceRoot":"","sources":["../../src/structures/Registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAiC;AAEjC,4CAAiF;AACjF,gDAAuB;AACvB,oCAAkF;AAClF,2CAA8C;AAC9C,0DAAgC;AAGhC,6CAA6C;AAC7C,uCAAwB;AAOxB,MAAa,QAAQ;IACnB,YAAmB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAExC,YAAO,GAA+B,IAAI,uBAAU,EAAE,CAAA;IA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EAAE,IAAI;qBACd,CAAC,CAAA;iBACH;gBAAC,OAAO,CAAM,EAAE;oBACf,OAAO,CAAC,IAAI,CAAC;wBACX,KAAK,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM,CAAC,IAAK;wBAClB,OAAO,EAAE,KAAK;qBACf,CAAC,CAAA;iBACH;aACF;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;KAAA;CACF;AAtMD,4BAsMC"}
|
package/dist/structures/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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("./Module"), exports);
|
|
14
|
-
__exportStar(require("./CommandClient"), exports);
|
|
15
|
-
__exportStar(require("./Registry"), exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwB;AACxB,kDAA+B;AAC/B,6CAA0B"}
|
package/dist/typings.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Command } from './command';
|
|
2
|
-
import { CommandClient } from './structures';
|
|
3
|
-
import { SlashCommand } from './slashCommand';
|
|
4
|
-
declare module 'discord.js' {
|
|
5
|
-
interface Message {
|
|
6
|
-
data: {
|
|
7
|
-
command: Command | null;
|
|
8
|
-
prefix: string;
|
|
9
|
-
cts: CommandClient;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
interface CommandInteraction {
|
|
13
|
-
data: {
|
|
14
|
-
command: SlashCommand;
|
|
15
|
-
cts: CommandClient;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
package/dist/typings.js
DELETED
package/dist/typings.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typings.js","sourceRoot":"","sources":["../src/typings.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const checkTarget: (target: Object) => void;
|
package/dist/utils.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkTarget = void 0;
|
|
4
|
-
const structures_1 = require("./structures");
|
|
5
|
-
const error_1 = require("./error");
|
|
6
|
-
const checkTarget = (target) => {
|
|
7
|
-
if (!(target instanceof structures_1.Module))
|
|
8
|
-
throw new error_1.InvalidTargetError();
|
|
9
|
-
};
|
|
10
|
-
exports.checkTarget = checkTarget;
|
|
11
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACrC,mCAA4C;AAErC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,IAAI,CAAC,CAAC,MAAM,YAAY,mBAAM,CAAC;QAAE,MAAM,IAAI,0BAAkB,EAAE,CAAA;AACjE,CAAC,CAAA;AAFY,QAAA,WAAW,eAEvB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BuiltInModule } from './BuiltInModule'
|
|
2
|
-
import { slashArgumentConverter } from '../command'
|
|
3
|
-
import { Client, CommandInteraction, CommandInteractionOptionResolver } from 'discord.js'
|
|
4
|
-
import { CommandClient } from '../structures'
|
|
5
|
-
|
|
6
|
-
export class BuiltinSlashCommandConverters extends BuiltInModule {
|
|
7
|
-
client: Client
|
|
8
|
-
|
|
9
|
-
constructor(private cts: CommandClient) {
|
|
10
|
-
super()
|
|
11
|
-
this.client = cts.client
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@slashArgumentConverter(CommandInteraction)
|
|
15
|
-
message(interaction: CommandInteraction) {
|
|
16
|
-
return interaction
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@slashArgumentConverter(CommandInteractionOptionResolver)
|
|
20
|
-
optionResolver(interaction: CommandInteraction): CommandInteractionOptionResolver {
|
|
21
|
-
return interaction.options as CommandInteractionOptionResolver
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SlashCommandBuilder } from '@discordjs/builders'
|
|
2
|
-
import { Module } from '../structures'
|
|
3
|
-
import { Snowflake } from 'discord.js'
|
|
4
|
-
import { KSlashCommandChecks } from '../constants'
|
|
5
|
-
import { SlashCheckFunction } from '../command'
|
|
6
|
-
|
|
7
|
-
export type SlashArgument = {
|
|
8
|
-
type: any
|
|
9
|
-
name?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class SlashCommand {
|
|
13
|
-
get checks(): SlashCheckFunction[] {
|
|
14
|
-
return Reflect.getMetadata(KSlashCommandChecks, this.module, this.key) || []
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
execute(module: Module, args: any[]) {
|
|
18
|
-
return this.run.apply(module, args)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
public commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
|
23
|
-
private run: Function,
|
|
24
|
-
public module: Module,
|
|
25
|
-
public params: SlashArgument[],
|
|
26
|
-
public guild: Snowflake | Snowflake[] | undefined,
|
|
27
|
-
private key: string | symbol,
|
|
28
|
-
) {}
|
|
29
|
-
}
|