oopscord.js 0.0.29 → 0.1.0
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/LICENSE +674 -201
- package/README.md +212 -11
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/structures/Constants.d.ts +2 -2
- package/dist/structures/Constants.d.ts.map +1 -1
- package/dist/structures/Constants.js +1 -0
- package/dist/structures/Constants.js.map +1 -0
- package/dist/structures/DiscordApp.d.ts +28 -10
- package/dist/structures/DiscordApp.d.ts.map +1 -1
- package/dist/structures/DiscordApp.js +681 -295
- package/dist/structures/DiscordApp.js.map +1 -0
- package/dist/structures/Plugin.d.ts +68 -0
- package/dist/structures/Plugin.d.ts.map +1 -1
- package/dist/structures/Plugin.js +28 -1
- package/dist/structures/Plugin.js.map +1 -0
- package/dist/structures/PluginManager.d.ts +122 -0
- package/dist/structures/PluginManager.d.ts.map +1 -0
- package/dist/structures/PluginManager.js +371 -0
- package/dist/structures/PluginManager.js.map +1 -0
- package/dist/structures/components/BaseButton.d.ts +2 -5
- package/dist/structures/components/BaseButton.d.ts.map +1 -1
- package/dist/structures/components/BaseButton.js +9 -14
- package/dist/structures/components/BaseButton.js.map +1 -0
- package/dist/structures/components/BaseModal.d.ts +13 -21
- package/dist/structures/components/BaseModal.d.ts.map +1 -1
- package/dist/structures/components/BaseModal.js +86 -132
- package/dist/structures/components/BaseModal.js.map +1 -0
- package/dist/structures/components/BaseSelectMenu.d.ts +2 -5
- package/dist/structures/components/BaseSelectMenu.d.ts.map +1 -1
- package/dist/structures/components/BaseSelectMenu.js +21 -25
- package/dist/structures/components/BaseSelectMenu.js.map +1 -0
- package/dist/structures/components/Listener.d.ts +18 -0
- package/dist/structures/components/Listener.d.ts.map +1 -0
- package/dist/structures/components/Listener.js +22 -0
- package/dist/structures/components/Listener.js.map +1 -0
- package/dist/structures/components/index.d.ts +1 -0
- package/dist/structures/components/index.d.ts.map +1 -1
- package/dist/structures/components/index.js +2 -0
- package/dist/structures/components/index.js.map +1 -0
- package/dist/structures/decorators/CommandDecorator.d.ts +39 -38
- package/dist/structures/decorators/CommandDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/CommandDecorator.js +145 -250
- package/dist/structures/decorators/CommandDecorator.js.map +1 -0
- package/dist/structures/decorators/Constants.d.ts +12 -8
- package/dist/structures/decorators/Constants.d.ts.map +1 -1
- package/dist/structures/decorators/Constants.js +13 -8
- package/dist/structures/decorators/Constants.js.map +1 -0
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts +11 -19
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/DiscordModuleDecorator.js +12 -54
- package/dist/structures/decorators/DiscordModuleDecorator.js.map +1 -0
- package/dist/structures/decorators/EventDecorator.d.ts +45 -0
- package/dist/structures/decorators/EventDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/EventDecorator.js +52 -0
- package/dist/structures/decorators/EventDecorator.js.map +1 -0
- package/dist/structures/decorators/ExecutionDecorator.d.ts +19 -0
- package/dist/structures/decorators/ExecutionDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/ExecutionDecorator.js +23 -0
- package/dist/structures/decorators/ExecutionDecorator.js.map +1 -0
- package/dist/structures/decorators/InjectionMetadata.d.ts +35 -0
- package/dist/structures/decorators/InjectionMetadata.d.ts.map +1 -0
- package/dist/structures/decorators/InjectionMetadata.js +34 -0
- package/dist/structures/decorators/InjectionMetadata.js.map +1 -0
- package/dist/structures/decorators/InteractionHandlerDecorator.d.ts +17 -2
- package/dist/structures/decorators/InteractionHandlerDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/InteractionHandlerDecorator.js +48 -7
- package/dist/structures/decorators/InteractionHandlerDecorator.js.map +1 -0
- package/dist/structures/decorators/MessageComponentDecorator.d.ts +25 -40
- package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/MessageComponentDecorator.js +66 -78
- package/dist/structures/decorators/MessageComponentDecorator.js.map +1 -0
- package/dist/structures/decorators/Metadata.d.ts +16 -0
- package/dist/structures/decorators/Metadata.d.ts.map +1 -0
- package/dist/structures/decorators/Metadata.js +50 -0
- package/dist/structures/decorators/Metadata.js.map +1 -0
- package/dist/structures/decorators/PluginDecorator.d.ts +41 -0
- package/dist/structures/decorators/PluginDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/PluginDecorator.js +36 -0
- package/dist/structures/decorators/PluginDecorator.js.map +1 -0
- package/dist/structures/decorators/UseDecorator.d.ts +44 -0
- package/dist/structures/decorators/UseDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/UseDecorator.js +49 -0
- package/dist/structures/decorators/UseDecorator.js.map +1 -0
- package/dist/structures/decorators/index.d.ts +4 -0
- package/dist/structures/decorators/index.d.ts.map +1 -1
- package/dist/structures/decorators/index.js +5 -0
- package/dist/structures/decorators/index.js.map +1 -0
- package/dist/structures/index.d.ts +3 -1
- package/dist/structures/index.d.ts.map +1 -1
- package/dist/structures/index.js +5 -1
- package/dist/structures/index.js.map +1 -0
- package/dist/utils/Util.d.ts +2 -0
- package/dist/utils/Util.d.ts.map +1 -1
- package/dist/utils/Util.js +23 -8
- package/dist/utils/Util.js.map +1 -0
- package/dist/utils/cache.d.ts +4 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +17 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/customId.d.ts +12 -0
- package/dist/utils/customId.d.ts.map +1 -0
- package/dist/utils/customId.js +49 -0
- package/dist/utils/customId.js.map +1 -0
- package/package.json +35 -9
- package/bun.lock +0 -264
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginRuntime = exports.PluginManager = void 0;
|
|
4
|
+
exports.describeError = describeError;
|
|
5
|
+
const Plugin_1 = require("./Plugin");
|
|
6
|
+
/** Formats an error for logging, including the original error of a {@link PluginError}. @internal */
|
|
7
|
+
function describeError(error) {
|
|
8
|
+
if (!(error instanceof Error))
|
|
9
|
+
return String(error);
|
|
10
|
+
const text = error.stack ?? error.message;
|
|
11
|
+
return error instanceof Plugin_1.PluginError && error.cause !== undefined ? text + "\nCaused by: " + describeError(error.cause) : text;
|
|
12
|
+
}
|
|
13
|
+
const ignore = () => { };
|
|
14
|
+
/**
|
|
15
|
+
* Looks up the plugins of an application and enables or disables them at runtime, as `app.plugins`.
|
|
16
|
+
*
|
|
17
|
+
* Disabling runs `onDisable` and takes the plugin out of service without a restart: its hooks stop running,
|
|
18
|
+
* interactions for handlers it owns are rejected, its event handlers stop firing, and `getCommandManifest()` leaves
|
|
19
|
+
* its commands out (call `deployCommands()` afterwards to remove them from Discord). Handlers already running are not
|
|
20
|
+
* interrupted. Plugins that depend on it are disabled first. Enabling requires its dependencies to be enabled.
|
|
21
|
+
*/
|
|
22
|
+
class PluginManager {
|
|
23
|
+
host;
|
|
24
|
+
/** In dependency order: every plugin comes after the plugins it depends on. */
|
|
25
|
+
entries = [];
|
|
26
|
+
constructor(host) {
|
|
27
|
+
this.host = host;
|
|
28
|
+
}
|
|
29
|
+
get(plugin) {
|
|
30
|
+
return this.find(plugin)?.plugin;
|
|
31
|
+
}
|
|
32
|
+
/** Lists every plugin in dependency order. */
|
|
33
|
+
list() {
|
|
34
|
+
return this.entries.map(entry => ({
|
|
35
|
+
name: entry.name,
|
|
36
|
+
version: entry.plugin.version,
|
|
37
|
+
state: entry.state,
|
|
38
|
+
plugin: entry.plugin,
|
|
39
|
+
depends: entry.depends.map(dependency => dependency.name),
|
|
40
|
+
softDepends: entry.softDepends.map(dependency => dependency.name)
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
isEnabled(plugin) {
|
|
44
|
+
return this.find(plugin)?.state === "enabled";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Enables a plugin that is disabled or failed, running `onEnable`. The application initializes first if it has
|
|
48
|
+
* not. Rejects if a dependency is not enabled or `onEnable` fails; do not call it from inside an `onEnable`.
|
|
49
|
+
*/
|
|
50
|
+
async enable(plugin) {
|
|
51
|
+
const entry = this.require(plugin);
|
|
52
|
+
await this.host.initialize();
|
|
53
|
+
// Join an enable in progress instead of running onEnable twice; let a disable finish first.
|
|
54
|
+
while (entry.transition) {
|
|
55
|
+
if (entry.state === "enabling")
|
|
56
|
+
return entry.transition;
|
|
57
|
+
await this.settle(entry);
|
|
58
|
+
}
|
|
59
|
+
if (entry.state === "enabled")
|
|
60
|
+
return;
|
|
61
|
+
const missing = entry.depends.find(dependency => dependency.state !== "enabled");
|
|
62
|
+
if (missing)
|
|
63
|
+
throw new Error(`Plugin "${entry.name}" requires "${missing.name}" to be enabled first.`);
|
|
64
|
+
await this.enableEntry(entry);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Disables a plugin and, first, every enabled plugin that depends on it. Resolves with the names disabled, in order.
|
|
68
|
+
* Every plugin ends up disabled even when an `onDisable` fails; the failures reject together as an `AggregateError`.
|
|
69
|
+
*/
|
|
70
|
+
async disable(plugin) {
|
|
71
|
+
const target = this.require(plugin);
|
|
72
|
+
await this.host.initialize();
|
|
73
|
+
const affected = new Set([target]);
|
|
74
|
+
for (const entry of this.entries)
|
|
75
|
+
if (entry.depends.some(dependency => affected.has(dependency)))
|
|
76
|
+
affected.add(entry);
|
|
77
|
+
const { disabled, errors } = await this.disableEntries(this.entries.filter(entry => affected.has(entry)).reverse());
|
|
78
|
+
if (errors.length)
|
|
79
|
+
throw new AggregateError(errors, `Disabling plugin "${target.name}" failed.`);
|
|
80
|
+
return disabled;
|
|
81
|
+
}
|
|
82
|
+
find(plugin) {
|
|
83
|
+
if (typeof plugin === "string")
|
|
84
|
+
return this.entries.find(entry => entry.name === plugin);
|
|
85
|
+
if (typeof plugin === "function")
|
|
86
|
+
return this.entries.find(entry => entry.plugin instanceof plugin);
|
|
87
|
+
return this.entries.find(entry => entry.plugin === plugin);
|
|
88
|
+
}
|
|
89
|
+
require(plugin) {
|
|
90
|
+
const entry = this.find(plugin);
|
|
91
|
+
if (!entry)
|
|
92
|
+
throw new Error(`Unknown plugin ${typeof plugin === "string" ? `"${plugin}"` : typeof plugin === "function" ? plugin.name : "instance"}.`);
|
|
93
|
+
return entry;
|
|
94
|
+
}
|
|
95
|
+
/** Waits for any enable or disable in progress. */
|
|
96
|
+
async settle(entry) {
|
|
97
|
+
while (entry.transition)
|
|
98
|
+
await entry.transition.catch(ignore);
|
|
99
|
+
}
|
|
100
|
+
/** Runs a hook, failing with a {@link PluginError} when it throws or exceeds the timeout. */
|
|
101
|
+
async call(entry, hook, run) {
|
|
102
|
+
const limit = entry.plugin.timeout ?? this.host.timeout;
|
|
103
|
+
let timer;
|
|
104
|
+
let timeout;
|
|
105
|
+
try {
|
|
106
|
+
let pending;
|
|
107
|
+
try {
|
|
108
|
+
pending = Promise.resolve(run());
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
pending = Promise.reject(error);
|
|
112
|
+
}
|
|
113
|
+
if (!(limit > 0))
|
|
114
|
+
return await pending;
|
|
115
|
+
const expiry = new Promise((_resolve, reject) => {
|
|
116
|
+
timer = setTimeout(() => {
|
|
117
|
+
timeout = new Plugin_1.PluginError(entry.name, hook, `Plugin "${entry.name}" timed out in ${hook} after ${limit}ms.`);
|
|
118
|
+
reject(timeout);
|
|
119
|
+
}, limit);
|
|
120
|
+
});
|
|
121
|
+
// A hook that fails after its timeout must not become an unhandled rejection.
|
|
122
|
+
pending.catch(ignore);
|
|
123
|
+
return await Promise.race([pending, expiry]);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error === timeout)
|
|
127
|
+
throw error;
|
|
128
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
129
|
+
throw new Plugin_1.PluginError(entry.name, hook, `Plugin "${entry.name}" failed in ${hook}: ${reason}`, { cause: error });
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
enableEntry(entry) {
|
|
136
|
+
const transition = (async () => {
|
|
137
|
+
entry.state = "enabling";
|
|
138
|
+
try {
|
|
139
|
+
await this.call(entry, "onEnable", () => entry.plugin.onEnable?.(this.host.context()));
|
|
140
|
+
entry.state = "enabled";
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
entry.state = "failed";
|
|
144
|
+
// onDisable always follows an attempted onEnable, so partly acquired resources can be released.
|
|
145
|
+
try {
|
|
146
|
+
await this.call(entry, "onDisable", () => entry.plugin.onDisable?.(this.host.context()));
|
|
147
|
+
}
|
|
148
|
+
catch (cleanupError) {
|
|
149
|
+
this.logError(cleanupError);
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
})().finally(() => { entry.transition = undefined; });
|
|
154
|
+
entry.transition = transition;
|
|
155
|
+
return transition;
|
|
156
|
+
}
|
|
157
|
+
disableEntry(entry) {
|
|
158
|
+
const transition = (async () => {
|
|
159
|
+
entry.state = "disabling";
|
|
160
|
+
try {
|
|
161
|
+
await this.call(entry, "onDisable", () => entry.plugin.onDisable?.(this.host.context()));
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
entry.state = "disabled";
|
|
165
|
+
}
|
|
166
|
+
})().finally(() => { entry.transition = undefined; });
|
|
167
|
+
entry.transition = transition;
|
|
168
|
+
return transition;
|
|
169
|
+
}
|
|
170
|
+
/** Disables the enabled plugins among `entries`, in the order given, collecting failures instead of stopping. */
|
|
171
|
+
async disableEntries(entries) {
|
|
172
|
+
const disabled = [];
|
|
173
|
+
const errors = [];
|
|
174
|
+
for (const entry of entries) {
|
|
175
|
+
// Check again after waiting: another call may have started a transition before this one resumed.
|
|
176
|
+
while (entry.transition)
|
|
177
|
+
await this.settle(entry);
|
|
178
|
+
if (entry.state !== "enabled")
|
|
179
|
+
continue;
|
|
180
|
+
try {
|
|
181
|
+
await this.disableEntry(entry);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
errors.push(error);
|
|
185
|
+
}
|
|
186
|
+
disabled.push(entry.name);
|
|
187
|
+
}
|
|
188
|
+
return { disabled, errors };
|
|
189
|
+
}
|
|
190
|
+
logError(error) {
|
|
191
|
+
this.host.logger.error(describeError(error));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.PluginManager = PluginManager;
|
|
195
|
+
/** The part of the manager that only the application uses. @internal */
|
|
196
|
+
class PluginRuntime extends PluginManager {
|
|
197
|
+
/**
|
|
198
|
+
* Names the plugins, resolves their dependencies, and fixes the enable order.
|
|
199
|
+
* Returns one entry per registration, in the order given.
|
|
200
|
+
*/
|
|
201
|
+
register(registrations) {
|
|
202
|
+
if (this.entries.length > 0)
|
|
203
|
+
throw new Error("Plugins are already registered.");
|
|
204
|
+
const entries = registrations.map(registration => ({ ...registration, name: "", state: "pending", depends: [], softDepends: [] }));
|
|
205
|
+
const used = new Set();
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
const name = entry.plugin.name;
|
|
208
|
+
if (name === undefined)
|
|
209
|
+
continue;
|
|
210
|
+
if (typeof name !== "string" || name.length === 0)
|
|
211
|
+
throw new TypeError("Plugin name must be a non-empty string.");
|
|
212
|
+
if (used.has(name))
|
|
213
|
+
throw new TypeError("Duplicate plugin name: " + name);
|
|
214
|
+
used.add(name);
|
|
215
|
+
entry.name = name;
|
|
216
|
+
}
|
|
217
|
+
entries.forEach((entry, index) => {
|
|
218
|
+
if (entry.name)
|
|
219
|
+
return;
|
|
220
|
+
// Unnamed plugins take their class name, with a suffix when it is already taken.
|
|
221
|
+
const constructor = entry.plugin.constructor;
|
|
222
|
+
const base = constructor && constructor !== Object && constructor.name ? constructor.name : "plugin-" + (index + 1);
|
|
223
|
+
let name = base;
|
|
224
|
+
for (let n = 2; used.has(name); n++)
|
|
225
|
+
name = base + "#" + n;
|
|
226
|
+
used.add(name);
|
|
227
|
+
entry.name = name;
|
|
228
|
+
});
|
|
229
|
+
const lookup = (entry, reference) => {
|
|
230
|
+
if (typeof reference === "string")
|
|
231
|
+
return entries.find(candidate => candidate.name === reference);
|
|
232
|
+
// Prefer another plugin of that class; matching only itself is a self dependency.
|
|
233
|
+
const matches = entries.filter(candidate => candidate.plugin instanceof reference);
|
|
234
|
+
return matches.find(candidate => candidate !== entry) ?? matches[0]
|
|
235
|
+
?? entries.find(candidate => candidate !== entry && candidate.supports.some(support => support instanceof reference));
|
|
236
|
+
};
|
|
237
|
+
for (const entry of entries) {
|
|
238
|
+
// `depends` must resolve. A `@Use` is a dependency only when it names a plugin (registered, or a Plugin
|
|
239
|
+
// subclass that is missing) or a support another plugin provides. Anything else is shared by the application.
|
|
240
|
+
const references = [
|
|
241
|
+
...(entry.plugin.depends ?? []).map(reference => ({ reference, required: true })),
|
|
242
|
+
...(entry.uses ?? []).map(reference => ({ reference, required: reference.prototype instanceof Plugin_1.Plugin }))
|
|
243
|
+
];
|
|
244
|
+
for (const { reference, required } of references) {
|
|
245
|
+
const dependency = lookup(entry, reference);
|
|
246
|
+
if (!dependency && !required)
|
|
247
|
+
continue;
|
|
248
|
+
if (dependency === entry)
|
|
249
|
+
throw new TypeError(`Plugin "${entry.name}" cannot depend on itself.`);
|
|
250
|
+
if (!dependency)
|
|
251
|
+
throw new TypeError(`Plugin "${entry.name}" depends on missing plugin "${typeof reference === "string" ? reference : reference.name}".`);
|
|
252
|
+
if (!entry.depends.includes(dependency))
|
|
253
|
+
entry.depends.push(dependency);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Soft dependencies only order the plugins: a missing one is ignored, a hard dependency takes precedence,
|
|
257
|
+
// and an edge that would close a cycle is dropped because nothing requires it.
|
|
258
|
+
const reaches = (from, target, seen = new Set()) => {
|
|
259
|
+
if (from === target)
|
|
260
|
+
return true;
|
|
261
|
+
if (seen.has(from))
|
|
262
|
+
return false;
|
|
263
|
+
seen.add(from);
|
|
264
|
+
return [...from.depends, ...from.softDepends].some(next => reaches(next, target, seen));
|
|
265
|
+
};
|
|
266
|
+
for (const entry of entries) {
|
|
267
|
+
for (const reference of entry.plugin.softDepends ?? []) {
|
|
268
|
+
const dependency = lookup(entry, reference);
|
|
269
|
+
if (!dependency)
|
|
270
|
+
continue;
|
|
271
|
+
if (dependency === entry)
|
|
272
|
+
throw new TypeError(`Plugin "${entry.name}" cannot depend on itself.`);
|
|
273
|
+
if (entry.depends.includes(dependency) || entry.softDepends.includes(dependency))
|
|
274
|
+
continue;
|
|
275
|
+
if (reaches(dependency, entry)) {
|
|
276
|
+
this.host.logger.warn(`Plugin "${entry.name}" soft-depends on "${dependency.name}", which already follows it, so the order is not applied.`);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
entry.softDepends.push(dependency);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Depth-first in registration order: dependencies and soft dependencies first, otherwise the order given.
|
|
283
|
+
const sorted = [];
|
|
284
|
+
const visiting = [];
|
|
285
|
+
const visit = (entry) => {
|
|
286
|
+
if (sorted.includes(entry))
|
|
287
|
+
return;
|
|
288
|
+
const cycleStart = visiting.indexOf(entry);
|
|
289
|
+
if (cycleStart >= 0)
|
|
290
|
+
throw new TypeError("Circular plugin dependency: " + [...visiting.slice(cycleStart), entry].map(member => member.name).join(" -> "));
|
|
291
|
+
visiting.push(entry);
|
|
292
|
+
[...entry.depends, ...entry.softDepends].forEach(visit);
|
|
293
|
+
visiting.pop();
|
|
294
|
+
sorted.push(entry);
|
|
295
|
+
};
|
|
296
|
+
entries.forEach(visit);
|
|
297
|
+
this.entries = sorted;
|
|
298
|
+
return entries;
|
|
299
|
+
}
|
|
300
|
+
/** Enables every pending plugin in dependency order. A failure rejects unless that plugin is `isolate`d. */
|
|
301
|
+
async enableAll() {
|
|
302
|
+
for (const entry of this.entries) {
|
|
303
|
+
if (entry.state !== "pending")
|
|
304
|
+
continue;
|
|
305
|
+
const missing = entry.depends.find(dependency => dependency.state !== "enabled");
|
|
306
|
+
if (missing) {
|
|
307
|
+
entry.state = "disabled";
|
|
308
|
+
this.host.logger.warn(`Plugin "${entry.name}" was not enabled because "${missing.name}" is ${missing.state}.`);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
await this.enableEntry(entry);
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
if (!entry.plugin.isolate)
|
|
316
|
+
throw error;
|
|
317
|
+
this.logError(error);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/** Disables every enabled plugin, dependents first. Failures are logged and returned. */
|
|
322
|
+
async disableAll() {
|
|
323
|
+
const { errors } = await this.disableEntries([...this.entries].reverse());
|
|
324
|
+
for (const error of errors)
|
|
325
|
+
this.logError(error);
|
|
326
|
+
return errors;
|
|
327
|
+
}
|
|
328
|
+
/** Enabled plugins that observe these handlers: global plugins, their owners, and an explicit owner. */
|
|
329
|
+
observers(handlers, owner) {
|
|
330
|
+
return this.entries.filter(entry => entry.state === "enabled" && (entry.global || entry === owner || handlers.some(handler => entry.owned.has(handler))));
|
|
331
|
+
}
|
|
332
|
+
/** Whether a plugin that owns any of these handlers, that `uses` names, or that provides a support `uses` names, is not enabled. */
|
|
333
|
+
blocked(handlers, uses = []) {
|
|
334
|
+
return this.entries.some(entry => entry.state !== "enabled" && (handlers.some(handler => entry.owned.has(handler))
|
|
335
|
+
|| uses.some(use => this.find(use) === entry || entry.supports.some(support => support instanceof use))));
|
|
336
|
+
}
|
|
337
|
+
/** Whether the plugin owning this handler has been taken out of service, so it should leave the deployed manifest. */
|
|
338
|
+
withdrawn(handler) {
|
|
339
|
+
return this.entries.some(entry => entry.owned.has(handler) && (entry.state === "disabling" || entry.state === "disabled" || entry.state === "failed"));
|
|
340
|
+
}
|
|
341
|
+
/** Runs `prefix` hooks in order. Resolves false when one rejects the interaction. */
|
|
342
|
+
async prefix(entries, context) {
|
|
343
|
+
for (const entry of entries) {
|
|
344
|
+
if (entry.state !== "enabled")
|
|
345
|
+
continue;
|
|
346
|
+
if (await this.call(entry, "prefix", () => entry.plugin.prefix?.(context)) === false)
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
/** Runs `postfix` hooks in order, skipping plugins disabled while the handler ran. */
|
|
352
|
+
async postfix(entries, context) {
|
|
353
|
+
for (const entry of entries) {
|
|
354
|
+
if (entry.state === "enabled")
|
|
355
|
+
await this.call(entry, "postfix", () => entry.plugin.postfix?.(context));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/** Reports a failure to the plugins that observe `handlers` (or `owner`); failures inside `onError` are logged. */
|
|
359
|
+
async error(error, interaction, handlers, owner) {
|
|
360
|
+
for (const entry of this.observers(handlers, owner)) {
|
|
361
|
+
try {
|
|
362
|
+
await this.call(entry, "onError", () => entry.plugin.onError?.(error, { ...this.host.context(), interaction }));
|
|
363
|
+
}
|
|
364
|
+
catch (pluginError) {
|
|
365
|
+
this.logError(pluginError);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
exports.PluginRuntime = PluginRuntime;
|
|
371
|
+
//# sourceMappingURL=PluginManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginManager.js","sourceRoot":"","sources":["../../src/structures/PluginManager.ts"],"names":[],"mappings":";;;AA4DA,sCAIC;AA9DD,qCAA6D;AAyD7D,qGAAqG;AACrG,SAAgB,aAAa,CAAC,KAAc;IACxC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC;IAC1C,OAAO,KAAK,YAAY,oBAAW,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,eAAe,GA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CAAC;IAED,mHAAmH;IACnH,KAAK,CAAC,KAAK,CAAC,KAAc,EAAE,WAAoC,EAAE,QAAmB,EAAE,KAAmB;QACtG,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC;gBAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YAAC,CAAC;YACxH,OAAO,WAAW,EAAE,CAAC;gBAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAAC,CAAC;QACvD,CAAC;IACL,CAAC;CACJ;AAzJD,sCAyJC"}
|
|
@@ -14,9 +14,8 @@ import { ButtonOptions } from "..";
|
|
|
14
14
|
* style: ButtonStyle.Primary
|
|
15
15
|
* })
|
|
16
16
|
* class MyButton extends BaseButton {
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* }
|
|
17
|
+
* @Interaction
|
|
18
|
+
* interaction!: ButtonInteraction;
|
|
20
19
|
*
|
|
21
20
|
* @Run
|
|
22
21
|
* async run() {
|
|
@@ -26,8 +25,6 @@ import { ButtonOptions } from "..";
|
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
27
|
export declare class BaseButton {
|
|
29
|
-
private static options;
|
|
30
|
-
private static button;
|
|
31
28
|
/** Returns {@link ButtonBuilder} that was created from the button options. */
|
|
32
29
|
static getButton(): ButtonBuilder;
|
|
33
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseButton.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseButton.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AACxD,OAAO,EAA8B,aAAa,EAAE,MAAM,IAAI,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAU;IACnB,8EAA8E;IAC9E,MAAM,CAAC,SAAS;IAQhB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAS/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseButton = void 0;
|
|
4
|
+
const Metadata_1 = require("../decorators/Metadata");
|
|
4
5
|
const discord_js_1 = require("discord.js");
|
|
5
6
|
const __1 = require("..");
|
|
6
7
|
const Util_1 = require("../../utils/Util");
|
|
@@ -18,9 +19,8 @@ const Util_1 = require("../../utils/Util");
|
|
|
18
19
|
* style: ButtonStyle.Primary
|
|
19
20
|
* })
|
|
20
21
|
* class MyButton extends BaseButton {
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* }
|
|
22
|
+
* @Interaction
|
|
23
|
+
* interaction!: ButtonInteraction;
|
|
24
24
|
*
|
|
25
25
|
* @Run
|
|
26
26
|
* async run() {
|
|
@@ -30,20 +30,12 @@ const Util_1 = require("../../utils/Util");
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
class BaseButton {
|
|
33
|
-
static options;
|
|
34
|
-
static button = null;
|
|
35
33
|
/** Returns {@link ButtonBuilder} that was created from the button options. */
|
|
36
34
|
static getButton() {
|
|
37
|
-
|
|
38
|
-
return this.button;
|
|
39
|
-
const options = Reflect.getMetadata(__1.BUTTON_OPTIONS_KEY, this);
|
|
35
|
+
const options = (0, Metadata_1.getMetadata)(__1.BUTTON_OPTIONS_KEY, this);
|
|
40
36
|
if (!options)
|
|
41
37
|
throw new TypeError("Failed to get the button.");
|
|
42
|
-
|
|
43
|
-
const button = create(options);
|
|
44
|
-
this.button = button;
|
|
45
|
-
// Return a copy of the button to prevent accidental mutations to the original button stored in the class.
|
|
46
|
-
return discord_js_1.ButtonBuilder.from(button.toJSON());
|
|
38
|
+
return create(options);
|
|
47
39
|
}
|
|
48
40
|
/**
|
|
49
41
|
* Returns a new {@link ButtonBuilder} with the specified options merged with the default options defined in the class.
|
|
@@ -51,7 +43,7 @@ class BaseButton {
|
|
|
51
43
|
* @param options The options to merge with the default options.
|
|
52
44
|
*/
|
|
53
45
|
static override(options) {
|
|
54
|
-
const currentOptions =
|
|
46
|
+
const currentOptions = (0, Metadata_1.getMetadata)(__1.BUTTON_OPTIONS_KEY, this);
|
|
55
47
|
if (!currentOptions)
|
|
56
48
|
throw new TypeError("Failed to get the button options.");
|
|
57
49
|
const newOptions = Util_1.Util.mergeDefault(currentOptions, options);
|
|
@@ -65,6 +57,8 @@ function create(options) {
|
|
|
65
57
|
button
|
|
66
58
|
.setStyle(options.style)
|
|
67
59
|
.setSKUId(options.skuId);
|
|
60
|
+
if (options.disabled !== undefined)
|
|
61
|
+
button.setDisabled(options.disabled);
|
|
68
62
|
return button;
|
|
69
63
|
}
|
|
70
64
|
if (options.style == discord_js_1.ButtonStyle.Link) {
|
|
@@ -85,3 +79,4 @@ function create(options) {
|
|
|
85
79
|
button.setDisabled(options.disabled);
|
|
86
80
|
return button;
|
|
87
81
|
}
|
|
82
|
+
//# sourceMappingURL=BaseButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseButton.js","sourceRoot":"","sources":["../../../src/structures/components/BaseButton.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,2CAAwD;AACxD,0BAA+D;AAC/D,2CAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,UAAU;IACnB,8EAA8E;IAC9E,MAAM,CAAC,S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AC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,KAAK;QAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,KAAK;QAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,QAAQ;QAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3D,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -61,8 +61,8 @@ export type ModalValueOverride = StringSelectValueOverride | TextInputValueOverr
|
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```ts
|
|
64
|
-
* import { ModalSubmitInteraction } from "discord.js";
|
|
65
|
-
* import { Modal, BaseModal, Interaction, Run } from "oopscord.js";
|
|
64
|
+
* import { ModalSubmitInteraction, TextInputStyle } from "discord.js";
|
|
65
|
+
* import { Modal, ModalLabel, BaseModal, Interaction, Run, TextInputFieldInjection } from "oopscord.js";
|
|
66
66
|
*
|
|
67
67
|
* @Modal({
|
|
68
68
|
* customId: "my_modal",
|
|
@@ -74,9 +74,11 @@ export type ModalValueOverride = StringSelectValueOverride | TextInputValueOverr
|
|
|
74
74
|
* component: { type: "text_input", customId: "my_text_input", style: TextInputStyle.Short, placeholder: "Enter something...", required: true }
|
|
75
75
|
* })
|
|
76
76
|
* class MyModal extends BaseModal {
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* @Interaction
|
|
78
|
+
* interaction!: ModalSubmitInteraction;
|
|
79
|
+
*
|
|
80
|
+
* @TextInputFieldInjection("my_text_input")
|
|
81
|
+
* textInputValue!: string;
|
|
80
82
|
*
|
|
81
83
|
* @Run
|
|
82
84
|
* async run() {
|
|
@@ -86,23 +88,13 @@ export type ModalValueOverride = StringSelectValueOverride | TextInputValueOverr
|
|
|
86
88
|
* ```
|
|
87
89
|
*/
|
|
88
90
|
export declare class BaseModal {
|
|
89
|
-
|
|
90
|
-
private static options;
|
|
91
|
-
private static components;
|
|
92
|
-
/** Returns a new {@link ModalBuilder} that was created from the modal options and components. */
|
|
91
|
+
/** Creates an independent builder from the decorated template. */
|
|
93
92
|
static getModal(): ModalBuilder;
|
|
94
|
-
/**
|
|
95
|
-
* Returns a new {@link ModalBuilder} with the specified options and component values merged with the default options and components defined in the class.
|
|
96
|
-
*
|
|
97
|
-
* @param options The options to merge with the default options.
|
|
98
|
-
* @param values The component values to merge with the default components. The `customId` property is used to match the values with the correct components, and the `type` property is used to determine which type of component the value is for.
|
|
99
|
-
*/
|
|
93
|
+
/** Overrides a copy of the template; label IDs and inner field IDs are distinct. */
|
|
100
94
|
static override(options?: Partial<ModalOptions>, ...values: ModalValueOverride[]): ModalBuilder;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*/
|
|
106
|
-
static getInput(itr: Exclude<RepliableInteraction, ModalSubmitInteraction>): Promise<ModalSubmitFields<import("discord.js").CacheType>>;
|
|
95
|
+
/** Shows a modal and collects input from the invoking user. Errors reject immediately. */
|
|
96
|
+
static getInput(itr: Exclude<RepliableInteraction, ModalSubmitInteraction>, options?: {
|
|
97
|
+
time?: number;
|
|
98
|
+
}): Promise<ModalSubmitFields>;
|
|
107
99
|
}
|
|
108
100
|
//# sourceMappingURL=BaseModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModal.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseModal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseModal.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseModal.ts"],"names":[],"mappings":"AACA,OAAO,EAAoF,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAqB,oBAAoB,EAAiE,MAAM,YAAY,CAAC;AAC/Q,OAAO,EAAsF,YAAY,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