@pikokr/command.ts 4.0.0 → 4.0.1-dev.1c9fbc0

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.
Files changed (206) hide show
  1. package/dist/index.d.ts +310 -10
  2. package/dist/index.js +1 -22
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -3
  5. package/publish-version.js +7 -3
  6. package/src/applicationCommand/AppCommand.ts +4 -0
  7. package/src/applicationCommand/decorator.ts +4 -0
  8. package/src/applicationCommand/index.ts +4 -0
  9. package/src/builtinModules/BuiltInModule.ts +4 -0
  10. package/src/builtinModules/BuiltinApplicationCommandConverters.ts +4 -0
  11. package/src/builtinModules/BuiltinCommandConverters.ts +4 -0
  12. package/src/builtinModules/CommandHandler.ts +4 -0
  13. package/src/builtinModules/index.ts +4 -0
  14. package/src/command/ArgumentConverter.ts +4 -0
  15. package/src/command/Command.ts +4 -0
  16. package/src/command/cooldown/adapter.ts +4 -0
  17. package/src/command/cooldown/decorator.ts +4 -0
  18. package/src/command/cooldown/error.ts +4 -0
  19. package/src/command/cooldown/index.ts +4 -0
  20. package/src/command/cooldown/type.ts +4 -0
  21. package/src/command/decorator.ts +4 -0
  22. package/src/command/index.ts +4 -0
  23. package/src/command/utils.ts +4 -0
  24. package/src/constants.ts +4 -0
  25. package/src/error/ArgumentConverterNotFound.ts +4 -0
  26. package/src/error/ArgumentNotProvided.ts +4 -0
  27. package/src/error/CommandCheckFailed.ts +4 -0
  28. package/src/error/CommandNotFound.ts +4 -0
  29. package/src/error/InvalidTargetError.ts +4 -0
  30. package/src/error/ModuleError.ts +4 -0
  31. package/src/error/PermissionRequired.ts +4 -0
  32. package/src/error/checks/DMOnlyCommand.ts +4 -0
  33. package/src/error/checks/GuildOnlyCommand.ts +4 -0
  34. package/src/error/checks/OwnerOnlyCommand.ts +4 -0
  35. package/src/error/checks/SlashCommandGlobalCheckError.ts +4 -0
  36. package/src/error/checks/index.ts +4 -0
  37. package/src/error/index.ts +4 -0
  38. package/src/index.ts +4 -0
  39. package/src/interface/index.ts +4 -0
  40. package/src/listener/Listener.ts +4 -0
  41. package/src/listener/decorator.ts +4 -0
  42. package/src/listener/index.ts +4 -0
  43. package/src/messageComponents/base.ts +4 -0
  44. package/src/messageComponents/button.ts +4 -0
  45. package/src/messageComponents/index.ts +4 -0
  46. package/src/messageComponents/selectMenu.ts +4 -0
  47. package/src/structures/CommandClient.ts +4 -0
  48. package/src/structures/Module.ts +4 -0
  49. package/src/structures/Registry.ts +37 -12
  50. package/src/structures/index.ts +4 -0
  51. package/src/typings.ts +4 -0
  52. package/src/utils.ts +4 -0
  53. package/test/index.ts +4 -0
  54. package/test/modules/dev.ts +4 -0
  55. package/test/modules/test.ts +5 -1
  56. package/tsup.config.ts +14 -0
  57. package/dist/applicationCommand/AppCommand.d.ts +0 -18
  58. package/dist/applicationCommand/AppCommand.js +0 -22
  59. package/dist/applicationCommand/AppCommand.js.map +0 -1
  60. package/dist/applicationCommand/decorator.d.ts +0 -10
  61. package/dist/applicationCommand/decorator.js +0 -39
  62. package/dist/applicationCommand/decorator.js.map +0 -1
  63. package/dist/applicationCommand/index.d.ts +0 -2
  64. package/dist/applicationCommand/index.js +0 -15
  65. package/dist/applicationCommand/index.js.map +0 -1
  66. package/dist/builtinModules/BuiltInModule.d.ts +0 -4
  67. package/dist/builtinModules/BuiltInModule.js +0 -13
  68. package/dist/builtinModules/BuiltInModule.js.map +0 -1
  69. package/dist/builtinModules/BuiltinApplicationCommandConverters.d.ts +0 -8
  70. package/dist/builtinModules/BuiltinApplicationCommandConverters.js +0 -13
  71. package/dist/builtinModules/BuiltinApplicationCommandConverters.js.map +0 -1
  72. package/dist/builtinModules/BuiltinCommandConverters.d.ts +0 -16
  73. package/dist/builtinModules/BuiltinCommandConverters.js +0 -127
  74. package/dist/builtinModules/BuiltinCommandConverters.js.map +0 -1
  75. package/dist/builtinModules/BuiltinSlashCommandConverters.d.ts +0 -10
  76. package/dist/builtinModules/BuiltinSlashCommandConverters.js +0 -42
  77. package/dist/builtinModules/BuiltinSlashCommandConverters.js.map +0 -1
  78. package/dist/builtinModules/CommandHandler.d.ts +0 -14
  79. package/dist/builtinModules/CommandHandler.js +0 -357
  80. package/dist/builtinModules/CommandHandler.js.map +0 -1
  81. package/dist/builtinModules/index.d.ts +0 -3
  82. package/dist/builtinModules/index.js +0 -16
  83. package/dist/builtinModules/index.js.map +0 -1
  84. package/dist/command/ArgumentConverter.d.ts +0 -15
  85. package/dist/command/ArgumentConverter.js +0 -25
  86. package/dist/command/ArgumentConverter.js.map +0 -1
  87. package/dist/command/Command.d.ts +0 -20
  88. package/dist/command/Command.js +0 -22
  89. package/dist/command/Command.js.map +0 -1
  90. package/dist/command/cooldown/adapter.d.ts +0 -10
  91. package/dist/command/cooldown/adapter.js +0 -31
  92. package/dist/command/cooldown/adapter.js.map +0 -1
  93. package/dist/command/cooldown/decorator.d.ts +0 -2
  94. package/dist/command/cooldown/decorator.js +0 -73
  95. package/dist/command/cooldown/decorator.js.map +0 -1
  96. package/dist/command/cooldown/error.d.ts +0 -4
  97. package/dist/command/cooldown/error.js +0 -11
  98. package/dist/command/cooldown/error.js.map +0 -1
  99. package/dist/command/cooldown/index.d.ts +0 -5
  100. package/dist/command/cooldown/index.js +0 -18
  101. package/dist/command/cooldown/index.js.map +0 -1
  102. package/dist/command/cooldown/type.d.ts +0 -8
  103. package/dist/command/cooldown/type.js +0 -13
  104. package/dist/command/cooldown/type.js.map +0 -1
  105. package/dist/command/decorator.d.ts +0 -17
  106. package/dist/command/decorator.js +0 -138
  107. package/dist/command/decorator.js.map +0 -1
  108. package/dist/command/index.d.ts +0 -5
  109. package/dist/command/index.js +0 -18
  110. package/dist/command/index.js.map +0 -1
  111. package/dist/command/utils.d.ts +0 -2
  112. package/dist/command/utils.js +0 -30
  113. package/dist/command/utils.js.map +0 -1
  114. package/dist/constants.d.ts +0 -14
  115. package/dist/constants.js +0 -18
  116. package/dist/constants.js.map +0 -1
  117. package/dist/error/ArgumentConverterNotFound.d.ts +0 -13
  118. package/dist/error/ArgumentConverterNotFound.js +0 -20
  119. package/dist/error/ArgumentConverterNotFound.js.map +0 -1
  120. package/dist/error/ArgumentNotProvided.d.ts +0 -8
  121. package/dist/error/ArgumentNotProvided.js +0 -13
  122. package/dist/error/ArgumentNotProvided.js.map +0 -1
  123. package/dist/error/CommandCheckFailed.d.ts +0 -13
  124. package/dist/error/CommandCheckFailed.js +0 -20
  125. package/dist/error/CommandCheckFailed.js.map +0 -1
  126. package/dist/error/CommandNotFound.d.ts +0 -7
  127. package/dist/error/CommandNotFound.js +0 -13
  128. package/dist/error/CommandNotFound.js.map +0 -1
  129. package/dist/error/InvalidTargetError.d.ts +0 -3
  130. package/dist/error/InvalidTargetError.js +0 -10
  131. package/dist/error/InvalidTargetError.js.map +0 -1
  132. package/dist/error/ModuleError.d.ts +0 -6
  133. package/dist/error/ModuleError.js +0 -14
  134. package/dist/error/ModuleError.js.map +0 -1
  135. package/dist/error/PermissionRequired.d.ts +0 -10
  136. package/dist/error/PermissionRequired.js +0 -19
  137. package/dist/error/PermissionRequired.js.map +0 -1
  138. package/dist/error/checks/DMOnlyCommand.d.ts +0 -3
  139. package/dist/error/checks/DMOnlyCommand.js +0 -10
  140. package/dist/error/checks/DMOnlyCommand.js.map +0 -1
  141. package/dist/error/checks/GuildOnlyCommand.d.ts +0 -3
  142. package/dist/error/checks/GuildOnlyCommand.js +0 -10
  143. package/dist/error/checks/GuildOnlyCommand.js.map +0 -1
  144. package/dist/error/checks/OwnerOnlyCommand.d.ts +0 -3
  145. package/dist/error/checks/OwnerOnlyCommand.js +0 -10
  146. package/dist/error/checks/OwnerOnlyCommand.js.map +0 -1
  147. package/dist/error/checks/SlashCommandGlobalCheckError.d.ts +0 -5
  148. package/dist/error/checks/SlashCommandGlobalCheckError.js +0 -11
  149. package/dist/error/checks/SlashCommandGlobalCheckError.js.map +0 -1
  150. package/dist/error/checks/index.d.ts +0 -3
  151. package/dist/error/checks/index.js +0 -16
  152. package/dist/error/checks/index.js.map +0 -1
  153. package/dist/error/index.d.ts +0 -7
  154. package/dist/error/index.js +0 -20
  155. package/dist/error/index.js.map +0 -1
  156. package/dist/interface/index.d.ts +0 -1
  157. package/dist/interface/index.js +0 -4
  158. package/dist/interface/index.js.map +0 -1
  159. package/dist/listener/Listener.d.ts +0 -5
  160. package/dist/listener/Listener.js +0 -11
  161. package/dist/listener/Listener.js.map +0 -1
  162. package/dist/listener/decorator.d.ts +0 -2
  163. package/dist/listener/decorator.js +0 -22
  164. package/dist/listener/decorator.js.map +0 -1
  165. package/dist/listener/index.d.ts +0 -2
  166. package/dist/listener/index.js +0 -15
  167. package/dist/listener/index.js.map +0 -1
  168. package/dist/messageComponents/base.d.ts +0 -10
  169. package/dist/messageComponents/base.js +0 -15
  170. package/dist/messageComponents/base.js.map +0 -1
  171. package/dist/messageComponents/button.d.ts +0 -5
  172. package/dist/messageComponents/button.js +0 -28
  173. package/dist/messageComponents/button.js.map +0 -1
  174. package/dist/messageComponents/index.d.ts +0 -2
  175. package/dist/messageComponents/index.js +0 -15
  176. package/dist/messageComponents/index.js.map +0 -1
  177. package/dist/messageComponents/selectMenu.d.ts +0 -5
  178. package/dist/messageComponents/selectMenu.js +0 -28
  179. package/dist/messageComponents/selectMenu.js.map +0 -1
  180. package/dist/slashCommand/SlashCommand.d.ts +0 -19
  181. package/dist/slashCommand/SlashCommand.js +0 -22
  182. package/dist/slashCommand/SlashCommand.js.map +0 -1
  183. package/dist/slashCommand/decorator.d.ts +0 -11
  184. package/dist/slashCommand/decorator.js +0 -39
  185. package/dist/slashCommand/decorator.js.map +0 -1
  186. package/dist/slashCommand/index.d.ts +0 -2
  187. package/dist/slashCommand/index.js +0 -15
  188. package/dist/slashCommand/index.js.map +0 -1
  189. package/dist/structures/CommandClient.d.ts +0 -45
  190. package/dist/structures/CommandClient.js +0 -94
  191. package/dist/structures/CommandClient.js.map +0 -1
  192. package/dist/structures/Module.d.ts +0 -21
  193. package/dist/structures/Module.js +0 -38
  194. package/dist/structures/Module.js.map +0 -1
  195. package/dist/structures/Registry.d.ts +0 -30
  196. package/dist/structures/Registry.js +0 -226
  197. package/dist/structures/Registry.js.map +0 -1
  198. package/dist/structures/index.d.ts +0 -3
  199. package/dist/structures/index.js +0 -16
  200. package/dist/structures/index.js.map +0 -1
  201. package/dist/typings.d.ts +0 -30
  202. package/dist/typings.js +0 -3
  203. package/dist/typings.js.map +0 -1
  204. package/dist/utils.d.ts +0 -1
  205. package/dist/utils.js +0 -11
  206. package/dist/utils.js.map +0 -1
@@ -1,38 +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 applicationCommandArgumentConverters() {
21
- return Reflect.getMetadata(constants_1.KSlashArgumentConverters, this) || [];
22
- }
23
- get applicationCommands() {
24
- return Reflect.getMetadata(constants_1.KApplicationCommands, this) || [];
25
- }
26
- get messageComponentHandlers() {
27
- return Reflect.getMetadata(constants_1.KMessageComponentHandlers, this) || [];
28
- }
29
- get path() {
30
- return Reflect.getMetadata(constants_1.KModulePath, this);
31
- }
32
- load() { }
33
- unload() { }
34
- beforeReload() { }
35
- afterReload() { }
36
- }
37
- exports.Module = Module;
38
- //# sourceMappingURL=Module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Module.js","sourceRoot":"","sources":["../../src/structures/Module.ts"],"names":[],"mappings":";;;AAAA,4CAAiK;AAQjK,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,oCAAoC;QACtC,OAAO,OAAO,CAAC,WAAW,CAAC,oCAAwB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAClE,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC9D,CAAC;IAED,IAAI,wBAAwB;QAC1B,OAAO,OAAO,CAAC,WAAW,CAAC,qCAAyB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACnE,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;AAzCD,wBAyCC"}
@@ -1,30 +0,0 @@
1
- import { CommandClient } from './CommandClient';
2
- import { Module } from './Module';
3
- import { Command, ApplicationCommandArgumentConverter } from '../command';
4
- import { Collection } from 'discord.js';
5
- import { ArgumentConverter } from '../command';
6
- import { AppCommand } from '../applicationCommand';
7
- import { MessageComponentHandler } from '../messageComponents/base';
8
- export declare class Registry {
9
- client: CommandClient;
10
- constructor(client: CommandClient);
11
- modules: Collection<symbol, Module>;
12
- private get logger();
13
- get commands(): Command[];
14
- get argumentConverters(): ArgumentConverter[];
15
- get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[];
16
- get applicationCommands(): AppCommand[];
17
- get messageComponentHandlers(): MessageComponentHandler[];
18
- registerModule(module: Module): Module;
19
- loadModulesIn(dir: string, absolute?: boolean): Promise<void>;
20
- loadModule(file: string, absolute?: boolean): Promise<Module>;
21
- syncCommands(): Promise<void>;
22
- unregisterModule(module: Module): Promise<Module>;
23
- unloadModule(module: Module): Promise<void>;
24
- reloadModule(module: Module): Promise<boolean>;
25
- reloadAll(): Promise<{
26
- path: string;
27
- success: boolean;
28
- error?: Error | undefined;
29
- }[]>;
30
- }
@@ -1,226 +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 fs = __importStar(require("fs"));
42
- class Registry {
43
- constructor(client) {
44
- this.client = client;
45
- this.modules = new discord_js_1.Collection();
46
- }
47
- get logger() {
48
- return this.client.logger.getChildLogger({
49
- name: 'Registry',
50
- });
51
- }
52
- get commands() {
53
- const result = [];
54
- for (const [, module] of this.modules) {
55
- result.push(...module.commands);
56
- }
57
- return result;
58
- }
59
- get argumentConverters() {
60
- const result = [];
61
- for (const [, module] of this.modules) {
62
- result.push(...module.argumentConverters);
63
- }
64
- return result;
65
- }
66
- get applicationCommandArgumentConverters() {
67
- const result = [];
68
- for (const [, module] of this.modules) {
69
- result.push(...module.applicationCommandArgumentConverters);
70
- }
71
- return result;
72
- }
73
- get applicationCommands() {
74
- const result = [];
75
- for (const [, module] of this.modules) {
76
- result.push(...module.applicationCommands);
77
- }
78
- return result;
79
- }
80
- get messageComponentHandlers() {
81
- const result = [];
82
- for (const [, module] of this.modules) {
83
- result.push(...module.messageComponentHandlers);
84
- }
85
- return result;
86
- }
87
- registerModule(module) {
88
- module.commandClient = this.client;
89
- this.modules.set(Symbol(module.constructor.name), module);
90
- const list = [];
91
- for (const listener of module.listeners) {
92
- const bound = listener.execute.bind(module);
93
- list.push({ event: listener.name, execute: bound });
94
- this.client.client.on(listener.name, bound);
95
- }
96
- Reflect.defineMetadata(constants_1.KListenerExecuteCache, list, module);
97
- return module;
98
- }
99
- loadModulesIn(dir, absolute = false) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- let p = absolute ? dir : path_1.default.join(require.main.path, dir);
102
- for (const i of walk_sync_1.default(p)) {
103
- if (fs.lstatSync(path_1.default.join(p, i)).isFile()) {
104
- if (i.endsWith('.map'))
105
- continue;
106
- yield this.loadModule(path_1.default.join(p, i), true);
107
- }
108
- }
109
- });
110
- }
111
- loadModule(file, absolute = false) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- let p = absolute ? file : path_1.default.join(require.main.path, file);
114
- let m;
115
- try {
116
- m = require(p);
117
- }
118
- catch (e) {
119
- throw new error_1.ModuleLoadError(p, e);
120
- }
121
- if (m.loaded)
122
- throw new Error('MODULE_ALREADY_LOADED');
123
- if (!m.install)
124
- throw new error_1.InvalidModuleError('Install function not found.');
125
- const mod = m.install(this.client);
126
- if (!(mod instanceof Module_1.Module))
127
- throw new error_1.InvalidTargetError();
128
- Reflect.defineMetadata(constants_1.KModulePath, require.resolve(p), mod);
129
- this.registerModule(mod);
130
- yield mod.load();
131
- m.loaded = true;
132
- return mod;
133
- });
134
- }
135
- syncCommands() {
136
- var _a;
137
- return __awaiter(this, void 0, void 0, function* () {
138
- this.logger.debug(`Syncing commands...`);
139
- const commands = this.applicationCommands.filter((x) => !x.guild);
140
- const guild = this.client.options.applicationCommands.guild;
141
- if (guild) {
142
- const syncForGuild = (g) => __awaiter(this, void 0, void 0, function* () {
143
- this.logger.debug(`Syncing for guild ${g.name}(${g.id})`);
144
- const commandsToRegister = [
145
- ...commands.map((x) => x.command),
146
- ...this.applicationCommands.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.command),
147
- ];
148
- this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`);
149
- yield g.commands.set(commandsToRegister);
150
- });
151
- if (typeof guild === 'string') {
152
- yield syncForGuild(yield this.client.client.guilds.fetch(guild));
153
- }
154
- else {
155
- for (const g of guild) {
156
- yield syncForGuild(yield this.client.client.guilds.fetch(g));
157
- }
158
- }
159
- }
160
- else {
161
- this.logger.debug('Syncing global...');
162
- yield ((_a = this.client.client.application) === null || _a === void 0 ? void 0 : _a.commands.set(commands.map((x) => x.command)));
163
- }
164
- this.logger.debug('Syncing ended.');
165
- });
166
- }
167
- unregisterModule(module) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- if (Reflect.getMetadata(constants_1.KBuiltInModule, module))
170
- throw new Error('Built-in modules cannot be unloaded');
171
- const symbol = this.modules.findKey((x) => x === module);
172
- if (!symbol)
173
- return module;
174
- yield module.unload();
175
- const list = Reflect.getMetadata(constants_1.KListenerExecuteCache, module);
176
- for (const listener of list) {
177
- this.client.client.removeListener(listener.event, listener.execute);
178
- }
179
- this.modules.delete(symbol);
180
- return module;
181
- });
182
- }
183
- unloadModule(module) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- const p = Reflect.getMetadata(constants_1.KModulePath, module);
186
- if (!p)
187
- throw new error_1.InvalidModuleError('This module is not loaded by loadModule.');
188
- yield this.unregisterModule(module);
189
- delete require.cache[p];
190
- });
191
- }
192
- reloadModule(module) {
193
- return __awaiter(this, void 0, void 0, function* () {
194
- yield module.beforeReload();
195
- const p = Reflect.getMetadata(constants_1.KModulePath, module);
196
- yield this.unloadModule(module);
197
- const mod = yield this.loadModule(p, true);
198
- yield mod.afterReload();
199
- return true;
200
- });
201
- }
202
- reloadAll() {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- const results = [];
205
- for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(constants_1.KBuiltInModule, x))) {
206
- try {
207
- yield this.reloadModule(module);
208
- results.push({
209
- path: module.path,
210
- success: true,
211
- });
212
- }
213
- catch (e) {
214
- results.push({
215
- error: e,
216
- path: module.path,
217
- success: false,
218
- });
219
- }
220
- }
221
- return results;
222
- });
223
- }
224
- }
225
- exports.Registry = Registry;
226
- //# sourceMappingURL=Registry.js.map
@@ -1 +0,0 @@
1
- {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C,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,CAAC,CAAC,CAAC,EAAE;gBACxG,IAAI;oBACF,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;oBAC/B,OAAO,CAAC,IAAI,CAAC;wBACX,IAAI,EAAE,MAAM,CAAC,IAAK;wBAClB,OAAO,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;AA5MD,4BA4MC"}
@@ -1,3 +0,0 @@
1
- export * from './Module';
2
- export * from './CommandClient';
3
- export * from './Registry';
@@ -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,30 +0,0 @@
1
- import type { Command } from './command';
2
- import { CommandClient } from './structures';
3
- import { AppCommand } from './applicationCommand';
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: AppCommand;
15
- cts: CommandClient;
16
- };
17
- }
18
- interface MessageComponentInteraction {
19
- data: {
20
- command: AppCommand;
21
- cts: CommandClient;
22
- };
23
- }
24
- interface ContextMenuInteraction {
25
- data: {
26
- command: AppCommand;
27
- cts: CommandClient;
28
- };
29
- }
30
- }
package/dist/typings.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=typings.js.map
@@ -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"}