gralonium 0.2.0 → 0.4.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.
Files changed (47) hide show
  1. package/lib/classes/Client.d.ts +9 -11
  2. package/lib/classes/Client.js +10 -13
  3. package/lib/classes/Context.d.ts +43 -4
  4. package/lib/classes/Context.js +251 -12
  5. package/lib/classes/Cooldowns.d.ts +3 -3
  6. package/lib/classes/Cooldowns.js +3 -8
  7. package/lib/classes/HelpCommand.d.ts +55 -13
  8. package/lib/classes/HelpCommand.js +319 -1
  9. package/lib/classes/Loader.d.ts +17 -11
  10. package/lib/classes/Loader.js +43 -42
  11. package/lib/classes/Utils.d.ts +4 -5
  12. package/lib/classes/Utils.js +32 -21
  13. package/lib/classes/builders/CommandBuilder.d.ts +10 -0
  14. package/lib/classes/builders/CommandBuilder.js +16 -0
  15. package/lib/classes/builders/ComponentsV2Builder.d.ts +285 -113
  16. package/lib/classes/builders/ComponentsV2Builder.js +1069 -182
  17. package/lib/classes/builders/GroupBuilder.d.ts +9 -0
  18. package/lib/classes/builders/GroupBuilder.js +16 -0
  19. package/lib/classes/builders/InteractionBuilder.d.ts +40 -25
  20. package/lib/classes/builders/InteractionBuilder.js +102 -1
  21. package/lib/classes/builders/components/StyleMapper.d.ts +1 -1
  22. package/lib/classes/builders/components/StyleMapper.js +2 -1
  23. package/lib/classes/builders/components/helpers.d.ts +68 -4
  24. package/lib/classes/builders/components/helpers.js +366 -7
  25. package/lib/classes/builders/components/templates.d.ts +151 -9
  26. package/lib/classes/builders/components/templates.js +376 -17
  27. package/lib/classes/builders/components/text.d.ts +24 -0
  28. package/lib/classes/builders/components/text.js +91 -0
  29. package/lib/classes/experiments/Confirmator.d.ts +45 -50
  30. package/lib/classes/experiments/Confirmator.js +37 -21
  31. package/lib/classes/experiments/Paginator.d.ts +49 -56
  32. package/lib/classes/experiments/Paginator.js +48 -19
  33. package/lib/classes/views/V2Paginator.d.ts +91 -0
  34. package/lib/classes/views/V2Paginator.js +268 -0
  35. package/lib/classes/views/V2View.d.ts +113 -0
  36. package/lib/classes/views/V2View.js +438 -0
  37. package/lib/experiments.d.ts +2 -0
  38. package/lib/experiments.js +9 -1
  39. package/lib/main.d.ts +3 -3
  40. package/lib/main.js +5 -5
  41. package/package.json +6 -15
  42. package/lib/events/interactionCreate.d.ts +0 -4
  43. package/lib/events/interactionCreate.js +0 -17
  44. package/lib/events/messageCreate.d.ts +0 -4
  45. package/lib/events/messageCreate.js +0 -17
  46. package/lib/events/messageUpdate.d.ts +0 -4
  47. package/lib/events/messageUpdate.js +0 -17
@@ -0,0 +1,438 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V2View = void 0;
4
+
5
+ const crypto_1 = require("crypto");
6
+ const discord_js_1 = require("discord.js");
7
+ const ComponentsV2Builder_js_1 = require("../builders/ComponentsV2Builder.js");
8
+ const helpers_js_1 = require("../builders/components/helpers.js");
9
+
10
+ function shortPrefix() {
11
+ if (typeof crypto_1.randomBytes === "function") {
12
+ return `v2_${crypto_1.randomBytes(4).toString("hex")}`;
13
+ }
14
+ return `v2_${Math.random().toString(36).slice(2, 10)}`;
15
+ }
16
+
17
+ function defaultCloneState(state) {
18
+ if (state === null || typeof state !== "object") return state;
19
+ if (Array.isArray(state)) return [...state];
20
+ return { ...state };
21
+ }
22
+
23
+ function normalizeMessageTarget(target) {
24
+ if (!target) return null;
25
+ if (target.resource?.message) return target.resource.message;
26
+ return target;
27
+ }
28
+
29
+ /**
30
+ * Interactive session controller for Discord Components V2 messages.
31
+ * Provides scoped custom IDs, reactive state rendering, unified component collection,
32
+ * third-party handling (`reject`, `allow`, `ephemeral-view`), and clean teardown (`disable`, `static`, `delete`).
33
+ */
34
+ class V2View {
35
+ #idPrefix;
36
+ #authorId;
37
+ #state;
38
+ #cloneState;
39
+ #render;
40
+ #actions = new Map();
41
+ #defaultAction = null;
42
+ #timeout;
43
+ #idle;
44
+ #thirdPartyMode;
45
+ #thirdPartyMessage;
46
+ #onEnd;
47
+ #onEndHandler;
48
+ #renderStatic;
49
+ #isEphemeral;
50
+ #filter;
51
+ #collector = null;
52
+ #message = null;
53
+ #stopped = false;
54
+ #endHandled = false;
55
+
56
+ constructor(options = {}) {
57
+ this.#idPrefix = String(options.idPrefix || shortPrefix());
58
+ this.#authorId = options.author?.id ?? options.authorId ?? options.ownerId ?? null;
59
+ this.#cloneState = typeof options.cloneState === "function" ? options.cloneState : defaultCloneState;
60
+ this.#state = this.#cloneState(options.state ?? {});
61
+ this.#render = typeof options.render === "function" ? options.render : null;
62
+ this.#renderStatic = typeof options.renderStatic === "function" ? options.renderStatic : null;
63
+
64
+ if (options.timeoutSeconds !== undefined) {
65
+ this.#timeout = Math.max(1000, Number(options.timeoutSeconds) * 1000);
66
+ } else if (options.time !== undefined) {
67
+ this.#timeout = Math.max(1000, Number(options.time));
68
+ } else if (options.timeout !== undefined) {
69
+ this.#timeout = Math.max(1000, Number(options.timeout));
70
+ } else {
71
+ this.#timeout = 120_000;
72
+ }
73
+
74
+ this.#idle = options.idle !== undefined ? Number(options.idle) : undefined;
75
+ this.#thirdPartyMode = options.thirdPartyMode || (this.#authorId ? "reject" : "allow");
76
+ this.#thirdPartyMessage = options.thirdPartyMessage || "Esta vista interactiva pertenece a otro usuario.";
77
+ this.#onEnd = options.onEnd || "disable";
78
+ this.#onEndHandler = typeof options.onEndHandler === "function" ? options.onEndHandler : null;
79
+ this.#isEphemeral = Boolean(options.isEphemeral);
80
+ this.#filter = typeof options.filter === "function" ? options.filter : null;
81
+
82
+ if (options.actions && typeof options.actions === "object") {
83
+ for (const [name, handler] of Object.entries(options.actions)) {
84
+ if (typeof handler === "function") {
85
+ this.#actions.set(name, handler);
86
+ }
87
+ }
88
+ }
89
+ if (typeof options.onAction === "function") {
90
+ this.#defaultAction = options.onAction;
91
+ }
92
+ }
93
+
94
+ get idPrefix() {
95
+ return this.#idPrefix;
96
+ }
97
+
98
+ get authorId() {
99
+ return this.#authorId;
100
+ }
101
+
102
+ get state() {
103
+ return this.#state;
104
+ }
105
+
106
+ get message() {
107
+ return this.#message;
108
+ }
109
+
110
+ get collector() {
111
+ return this.#collector;
112
+ }
113
+
114
+ get isEnded() {
115
+ return this.#stopped;
116
+ }
117
+
118
+ get isEphemeral() {
119
+ return this.#isEphemeral;
120
+ }
121
+
122
+ /**
123
+ * Builds a scoped `customId` belonging to this view (`<prefix>:<action>` or `<prefix>:<action>:<extra>`).
124
+ */
125
+ id(action, ...extra) {
126
+ const base = `${this.#idPrefix}:${action}`;
127
+ const rest = extra.filter((part) => part !== undefined && part !== null && part !== "");
128
+ return rest.length > 0 ? `${base}:${rest.join(":")}` : base;
129
+ }
130
+
131
+ /**
132
+ * Alias of `id(action, ...extra)`.
133
+ */
134
+ scopedId(action, ...extra) {
135
+ return this.id(action, ...extra);
136
+ }
137
+
138
+ setState(updater) {
139
+ if (typeof updater === "function") {
140
+ const next = updater(this.#state);
141
+ if (next !== undefined) this.#state = next;
142
+ } else if (updater && typeof updater === "object") {
143
+ this.#state = { ...(this.#state && typeof this.#state === "object" ? this.#state : {}), ...updater };
144
+ }
145
+ return this;
146
+ }
147
+
148
+ setRenderer(renderFn) {
149
+ this.#render = renderFn;
150
+ return this;
151
+ }
152
+
153
+ on(action, handler) {
154
+ this.#actions.set(String(action), handler);
155
+ return this;
156
+ }
157
+
158
+ action(action, handler) {
159
+ return this.on(action, handler);
160
+ }
161
+
162
+ #parseScopedCustomId(customId) {
163
+ if (typeof customId !== "string") return null;
164
+ const prefixWithSep = `${this.#idPrefix}:`;
165
+ if (!customId.startsWith(prefixWithSep)) return null;
166
+ const remainder = customId.slice(prefixWithSep.length);
167
+ const colonIdx = remainder.indexOf(":");
168
+ if (colonIdx === -1) {
169
+ return { action: remainder, subId: null, parts: [] };
170
+ }
171
+ const action = remainder.slice(0, colonIdx);
172
+ const rawSub = remainder.slice(colonIdx + 1);
173
+ return { action, subId: rawSub, parts: rawSub.split(":") };
174
+ }
175
+
176
+ #renderWithState(stateOverride = this.#state, extraCtx = {}) {
177
+ if (!this.#render) {
178
+ throw new Error("[V2View] A render function is required.");
179
+ }
180
+ return this.#render({
181
+ state: stateOverride,
182
+ view: this,
183
+ id: (action, ...rest) => this.id(action, ...rest),
184
+ scopedId: (action, ...rest) => this.id(action, ...rest),
185
+ ownerId: this.#authorId,
186
+ isEphemeral: this.#isEphemeral,
187
+ isEnded: this.#stopped,
188
+ ...extraCtx,
189
+ });
190
+ }
191
+
192
+ /**
193
+ * Renders the current view state into a ready-to-send Discord message payload.
194
+ */
195
+ toPayload(options = {}) {
196
+ const rendered = options.static && this.#renderStatic
197
+ ? this.#renderStatic({ state: this.#state, view: this, isEnded: true, isEphemeral: this.#isEphemeral })
198
+ : this.#renderWithState(this.#state, { isEnded: Boolean(options.isEnded ?? this.#stopped) });
199
+
200
+ if (ComponentsV2Builder_js_1.ComponentsV2Builder.isBuilder(rendered)) {
201
+ return rendered.toPayload({
202
+ ephemeral: options.ephemeral ?? this.#isEphemeral,
203
+ safeMentions: options.safeMentions,
204
+ allowedMentions: options.allowedMentions,
205
+ files: options.files,
206
+ });
207
+ }
208
+ return rendered;
209
+ }
210
+
211
+ /**
212
+ * Stops the view collector (if active) and applies the configured end behavior.
213
+ */
214
+ stop(reason = "stopped") {
215
+ this.#stopped = true;
216
+ if (this.#collector && !this.#collector.ended) {
217
+ this.#collector.stop(reason);
218
+ }
219
+ return this;
220
+ }
221
+
222
+ async #spawnEphemeralSession(interaction, parsed) {
223
+ const subView = new V2View({
224
+ authorId: interaction.user?.id,
225
+ state: this.#cloneState(this.#state),
226
+ cloneState: this.#cloneState,
227
+ render: this.#render,
228
+ renderStatic: this.#renderStatic,
229
+ timeout: this.#timeout,
230
+ idle: this.#idle,
231
+ thirdPartyMode: "reject",
232
+ thirdPartyMessage: this.#thirdPartyMessage,
233
+ onEnd: this.#onEnd === "delete" ? "disable" : this.#onEnd,
234
+ isEphemeral: true,
235
+ onAction: this.#defaultAction,
236
+ });
237
+
238
+ for (const [name, fn] of this.#actions.entries()) {
239
+ subView.on(name, fn);
240
+ }
241
+
242
+ const actionCtx = subView.#createActionContext(interaction, parsed);
243
+ const handler = subView.#actions.get(parsed.action) || subView.#defaultAction;
244
+ if (handler) {
245
+ await handler(actionCtx);
246
+ }
247
+
248
+ if (interaction.replied || interaction.deferred) {
249
+ return;
250
+ }
251
+
252
+ const payload = subView.toPayload({ ephemeral: true });
253
+ let replyResult = null;
254
+ try {
255
+ replyResult = await interaction.reply({ ...payload, withResponse: true });
256
+ } catch {
257
+ replyResult = await interaction.reply(payload);
258
+ }
259
+
260
+ const ephemeralMsg = normalizeMessageTarget(replyResult);
261
+ if (ephemeralMsg && typeof ephemeralMsg.createMessageComponentCollector === "function") {
262
+ subView.attach(ephemeralMsg);
263
+ }
264
+ }
265
+
266
+ #createActionContext(interaction, parsed) {
267
+ return {
268
+ interaction,
269
+ state: this.#state,
270
+ setState: (updater) => this.setState(updater),
271
+ view: this,
272
+ action: parsed.action,
273
+ subId: parsed.subId,
274
+ parts: parsed.parts,
275
+ customId: interaction.customId,
276
+ values: Array.isArray(interaction.values) ? interaction.values : [],
277
+ isEphemeral: this.#isEphemeral,
278
+ stop: (reason) => this.stop(reason),
279
+ id: (action, ...rest) => this.id(action, ...rest),
280
+ };
281
+ }
282
+
283
+ async #handleInteraction(interaction) {
284
+ const parsed = this.#parseScopedCustomId(interaction.customId);
285
+ if (!parsed) return;
286
+
287
+ if (this.#filter) {
288
+ const allowed = await this.#filter(interaction, this);
289
+ if (!allowed) return;
290
+ }
291
+
292
+ const userId = interaction.user?.id;
293
+ const isOwner = !this.#authorId || !userId || userId === this.#authorId;
294
+
295
+ if (!isOwner) {
296
+ if (this.#thirdPartyMode === "ephemeral-view") {
297
+ await this.#spawnEphemeralSession(interaction, parsed);
298
+ return;
299
+ }
300
+ if (this.#thirdPartyMode !== "allow") {
301
+ if (!interaction.replied && !interaction.deferred) {
302
+ await interaction
303
+ .reply({ content: this.#thirdPartyMessage, flags: discord_js_1.MessageFlags.Ephemeral })
304
+ .catch(() => null);
305
+ }
306
+ return;
307
+ }
308
+ }
309
+
310
+ const handler = this.#actions.get(parsed.action) || this.#defaultAction;
311
+ if (!handler) return;
312
+
313
+ const actionCtx = this.#createActionContext(interaction, parsed);
314
+ const result = await handler(actionCtx);
315
+
316
+ if (this.#stopped) {
317
+ if (!interaction.replied && !interaction.deferred && typeof interaction.deferUpdate === "function") {
318
+ await interaction.deferUpdate().catch(() => null);
319
+ }
320
+ return;
321
+ }
322
+
323
+ if (result === false || interaction.replied || interaction.deferred) {
324
+ return;
325
+ }
326
+
327
+ const nextPayload = this.toPayload({ ephemeral: this.#isEphemeral });
328
+ if (typeof interaction.update === "function") {
329
+ await interaction.update(nextPayload);
330
+ } else if (this.#message?.editable) {
331
+ await this.#message.edit(nextPayload);
332
+ }
333
+ }
334
+
335
+ async #runEndBehavior(reason) {
336
+ if (this.#endHandled) return;
337
+ this.#endHandled = true;
338
+ this.#stopped = true;
339
+
340
+ if (this.#onEndHandler) {
341
+ await this.#onEndHandler({ view: this, message: this.#message, reason, state: this.#state });
342
+ }
343
+
344
+ if (!this.#message || reason === "deleted") return;
345
+
346
+ if (this.#onEnd === "delete") {
347
+ if (typeof this.#message.delete === "function") {
348
+ await this.#message.delete().catch(() => null);
349
+ }
350
+ return;
351
+ }
352
+
353
+ if (this.#onEnd === "static") {
354
+ if (this.#renderStatic && this.#message.editable) {
355
+ const staticPayload = this.toPayload({ static: true, isEnded: true, ephemeral: this.#isEphemeral });
356
+ await this.#message.edit(staticPayload).catch(() => null);
357
+ return;
358
+ }
359
+ await helpers_js_1.disableMessageComponents(this.#message);
360
+ return;
361
+ }
362
+
363
+ if (this.#onEnd === "disable") {
364
+ await helpers_js_1.disableMessageComponents(this.#message);
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Attaches a component collector directly to an existing Discord Message (or InteractionCallbackResponse).
370
+ */
371
+ attach(messageTarget, collectorOptions = {}) {
372
+ const message = normalizeMessageTarget(messageTarget);
373
+ if (!message || typeof message.createMessageComponentCollector !== "function") {
374
+ throw new Error("[V2View] attach() requires a Discord Message with createMessageComponentCollector().");
375
+ }
376
+
377
+ this.#message = message;
378
+ this.#stopped = false;
379
+ this.#endHandled = false;
380
+
381
+ const opts = {
382
+ time: collectorOptions.time ?? this.#timeout,
383
+ ...(collectorOptions.idle ?? this.#idle ? { idle: collectorOptions.idle ?? this.#idle } : {}),
384
+ filter: (i) => Boolean(this.#parseScopedCustomId(i.customId)),
385
+ };
386
+
387
+ const collector = message.createMessageComponentCollector(opts);
388
+ this.#collector = collector;
389
+
390
+ collector.on("collect", async (interaction) => {
391
+ try {
392
+ await this.#handleInteraction(interaction);
393
+ } catch (err) {
394
+ if (!interaction.replied && !interaction.deferred) {
395
+ await interaction
396
+ .reply({ content: "Ocurrió un error al procesar esta acción.", flags: discord_js_1.MessageFlags.Ephemeral })
397
+ .catch(() => null);
398
+ }
399
+ if (typeof collectorOptions.onError === "function") {
400
+ collectorOptions.onError(err, interaction);
401
+ }
402
+ }
403
+ });
404
+
405
+ collector.on("end", async (_collected, reason) => {
406
+ await this.#runEndBehavior(reason);
407
+ });
408
+
409
+ return collector;
410
+ }
411
+
412
+ /**
413
+ * Renders and sends the view through a `Context` or `TextBasedChannel`, then attaches the collector automatically.
414
+ */
415
+ async send(target, sendOptions = {}) {
416
+ const payload = this.toPayload({
417
+ ephemeral: sendOptions.ephemeral ?? this.#isEphemeral,
418
+ safeMentions: sendOptions.safeMentions,
419
+ allowedMentions: sendOptions.allowedMentions,
420
+ files: sendOptions.files,
421
+ });
422
+
423
+ let sent;
424
+ if (target && typeof target.send === "function") {
425
+ sent = await target.send(payload, sendOptions);
426
+ } else {
427
+ throw new TypeError("[V2View] send() requires a Context or TextBasedChannel with a .send() method.");
428
+ }
429
+
430
+ const message = normalizeMessageTarget(sent);
431
+ const collector =
432
+ message && typeof message.createMessageComponentCollector === "function" ? this.attach(message, sendOptions) : null;
433
+
434
+ return { view: this, message, collector };
435
+ }
436
+ }
437
+
438
+ exports.V2View = V2View;
@@ -1,2 +1,4 @@
1
1
  export * from "./classes/experiments/Paginator";
2
2
  export * from "./classes/experiments/Confirmator";
3
+ export * from "./classes/views/V2View";
4
+ export * from "./classes/views/V2Paginator";
@@ -1 +1,9 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./classes/experiments/Paginator"),exports),tslib_1.__exportStar(require("./classes/experiments/Confirmator"),exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+
4
+ const tslib_1 = require("tslib");
5
+
6
+ tslib_1.__exportStar(require("./classes/experiments/Paginator"), exports);
7
+ tslib_1.__exportStar(require("./classes/experiments/Confirmator"), exports);
8
+ tslib_1.__exportStar(require("./classes/views/V2View"), exports);
9
+ tslib_1.__exportStar(require("./classes/views/V2Paginator"), exports);
package/lib/main.d.ts CHANGED
@@ -8,11 +8,11 @@ export * from "./classes/builders/InteractionBuilder.js";
8
8
  export * from "./classes/builders/GroupBuilder.js";
9
9
  export * from "./classes/builders/ParamsBuilder.js";
10
10
  export * from "./classes/builders/ComponentsV2Builder.js";
11
+ export * from "./classes/builders/components/text.js";
12
+ export * from "./classes/views/V2View.js";
13
+ export * from "./classes/views/V2Paginator.js";
11
14
  export * from "./classes/HelpCommand.js";
12
15
  export * from "./classes/Cooldowns.js";
13
16
  export * as Errors from "./classes/Errors.js";
14
17
  export * as Plugins from "./classes/Plugins.js";
15
- export * as ErineUtils from "./classes/Utils.js";
16
- export * as RedBotUtils from "./classes/Utils.js";
17
- export * as EnireUtils from "./classes/Utils.js";
18
18
  export * as GraloniumUtils from "./classes/Utils.js";
package/lib/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraloniumUtils = exports.EnireUtils = exports.ErineUtils = exports.RedBotUtils = exports.Plugins = exports.Errors = void 0;
3
+ exports.GraloniumUtils = exports.Plugins = exports.Errors = void 0;
4
4
 
5
5
  const tslib_1 = require("tslib");
6
6
 
@@ -14,12 +14,12 @@ tslib_1.__exportStar(require("./classes/builders/InteractionBuilder.js"), export
14
14
  tslib_1.__exportStar(require("./classes/builders/GroupBuilder.js"), exports);
15
15
  tslib_1.__exportStar(require("./classes/builders/ParamsBuilder.js"), exports);
16
16
  tslib_1.__exportStar(require("./classes/builders/ComponentsV2Builder.js"), exports);
17
+ tslib_1.__exportStar(require("./classes/builders/components/text.js"), exports);
18
+ tslib_1.__exportStar(require("./classes/views/V2View.js"), exports);
19
+ tslib_1.__exportStar(require("./classes/views/V2Paginator.js"), exports);
17
20
  tslib_1.__exportStar(require("./classes/HelpCommand.js"), exports);
18
21
  tslib_1.__exportStar(require("./classes/Cooldowns.js"), exports);
19
22
 
20
23
  exports.Errors = tslib_1.__importStar(require("./classes/Errors.js"));
21
24
  exports.Plugins = tslib_1.__importStar(require("./classes/Plugins.js"));
22
- exports.ErineUtils = tslib_1.__importStar(require("./classes/Utils.js"));
23
- exports.RedBotUtils = exports.ErineUtils;
24
- exports.EnireUtils = exports.ErineUtils;
25
- exports.GraloniumUtils = exports.ErineUtils;
25
+ exports.GraloniumUtils = tslib_1.__importStar(require("./classes/Utils.js"));
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "gralonium",
3
3
  "description": "i know.",
4
- "version": "0.2.0",
4
+ "version": "0.4.0",
5
5
  "license": "MIT",
6
6
  "author": "carzo",
7
-
8
7
  "type": "commonjs",
9
-
10
8
  "main": "./lib/main.js",
11
9
  "types": "./lib/main.d.ts",
12
-
13
10
  "exports": {
14
11
  ".": {
15
12
  "types": "./lib/main.d.ts",
@@ -24,46 +21,40 @@
24
21
  "default": "./lib/experiments.js"
25
22
  }
26
23
  },
27
-
28
24
  "files": [
29
25
  "lib/**/*"
30
26
  ],
31
-
32
27
  "sideEffects": false,
33
-
34
28
  "scripts": {
35
29
  "build": "node -e \"const fs=require('fs');const cp=require('child_process');if(!fs.existsSync('tsconfig.json')||!fs.existsSync('src')){console.log('Skipping build: tsconfig.json/src not found');process.exit(0)}cp.execSync('tsc -p tsconfig.json && tsc-alias -p tsconfig.json',{stdio:'inherit',shell:true})\"",
30
+ "test": "vitest run",
31
+ "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
36
32
  "watch": "tsc -w -p tsconfig.json",
37
33
  "dev": "npm run watch",
38
34
  "clean": "rimraf lib",
39
35
  "prepublishOnly": "npm run build"
40
36
  },
41
-
42
37
  "keywords": [
43
38
  "bot"
44
39
  ],
45
-
46
40
  "publishConfig": {
47
41
  "access": "public",
48
42
  "tag": "latest"
49
43
  },
50
-
51
44
  "engines": {
52
45
  "node": ">=18.0.0"
53
46
  },
54
-
55
47
  "peerDependencies": {
56
48
  "discord.js": "^14.0.0"
57
49
  },
58
-
59
50
  "dependencies": {
60
51
  "@sapphire/shapeshift": "^3.9.7",
61
52
  "tslib": "^2.6.2"
62
53
  },
63
-
64
54
  "devDependencies": {
65
- "typescript": "^5.4.5",
55
+ "rimraf": "^5.0.5",
66
56
  "tsc-alias": "^1.8.8",
67
- "rimraf": "^5.0.5"
57
+ "typescript": "^5.4.5",
58
+ "vitest": "^5.0.0"
68
59
  }
69
60
  }
@@ -1,4 +0,0 @@
1
- import { EventBuilder } from "../classes/builders/EventBuilder.js";
2
- import { ModuleData } from "../classes/Loader.js";
3
- import * as DJS from "discord.js";
4
- export declare const data: ModuleData<EventBuilder, [DJS.Interaction]>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.data = void 0;
4
-
5
- const EventBuilder_js_1 = require("../classes/builders/EventBuilder.js");
6
- const Utils_js_1 = require("../classes/Utils.js");
7
-
8
- exports.data = {
9
- data: new EventBuilder_js_1.EventBuilder({
10
- name: "interactionCreate",
11
- description: "Triggered when an interaction is created.",
12
- once: false,
13
- }),
14
- code: async function (bot, interaction) {
15
- await Utils_js_1.Utils.handleInteraction(bot, interaction);
16
- },
17
- };
@@ -1,4 +0,0 @@
1
- import { EventBuilder } from "../classes/builders/EventBuilder.js";
2
- import { ModuleData } from "../classes/Loader.js";
3
- import { Message } from "discord.js";
4
- export declare const data: ModuleData<EventBuilder, [Message]>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.data = void 0;
4
-
5
- const EventBuilder_js_1 = require("../classes/builders/EventBuilder.js");
6
- const Utils_js_1 = require("../classes/Utils.js");
7
-
8
- exports.data = {
9
- data: new EventBuilder_js_1.EventBuilder({
10
- name: "messageCreate",
11
- description: "Triggered when a message is created.",
12
- once: false,
13
- }),
14
- code: async function (bot, message) {
15
- await Utils_js_1.Utils.handleMessage(bot, message, false);
16
- },
17
- };
@@ -1,4 +0,0 @@
1
- import { EventBuilder } from "../classes/builders/EventBuilder.js";
2
- import { ModuleData } from "../classes/Loader.js";
3
- import { Message } from "discord.js";
4
- export declare const data: ModuleData<EventBuilder, [Message]>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.data = void 0;
4
-
5
- const EventBuilder_js_1 = require("../classes/builders/EventBuilder.js");
6
- const Utils_js_1 = require("../classes/Utils.js");
7
-
8
- exports.data = {
9
- data: new EventBuilder_js_1.EventBuilder({
10
- name: "messageUpdate",
11
- description: "Triggered when a message is updated.",
12
- once: false,
13
- }),
14
- code: async function (bot, _oldMessage, newMessage) {
15
- await Utils_js_1.Utils.handleMessage(bot, newMessage, true);
16
- },
17
- };