@arox/framework 0.1.2-beta.1 → 0.1.2-beta.2

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.js CHANGED
@@ -1,1194 +1,3 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
- // If the importer is in node compatibility mode or this is not an ESM
28
- // file that has been converted to a CommonJS file using a Babel-
29
- // compatible transform (i.e. "__esModule" has not been set), then set
30
- // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
33
- ));
34
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
-
36
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/util.ts
37
- function deleteMessageAfterSent(message, time = 15e3) {
38
- return new Promise((r) => {
39
- setTimeout(() => {
40
- message.delete().catch(() => {
41
- });
42
- r();
43
- }, time);
44
- });
45
- }
46
- function getPrefix(opts) {
47
- if (typeof opts === "string") {
48
- return opts;
49
- }
50
- if (opts.enabled && opts.prefix) {
51
- return opts.prefix;
52
- }
53
- return false;
54
- }
55
- var init_util = __esm({
56
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/util.ts"() {
57
- "use strict";
58
- }
59
- });
60
-
61
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/Files.ts
62
- function getFiles(baseDir) {
63
- return import_fast_glob.default.sync(["**/*.ts", "**/*.js"], {
64
- cwd: baseDir,
65
- absolute: true,
66
- ignore: [
67
- "**/*.d.ts",
68
- "node_modules/**",
69
- ".git/**",
70
- "dist/**",
71
- "lib/**",
72
- "out/**",
73
- "build/**",
74
- ".next/**",
75
- "coverage/**"
76
- ]
77
- });
78
- }
79
- function getProjectRoot() {
80
- if (!require.main?.filename) {
81
- return process.cwd();
82
- }
83
- return import_path.default.dirname(require.main.filename);
84
- }
85
- var import_fast_glob, import_path;
86
- var init_Files = __esm({
87
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/Files.ts"() {
88
- "use strict";
89
- import_fast_glob = __toESM(require("fast-glob"));
90
- import_path = __toESM(require("path"));
91
- }
92
- });
93
-
94
- // node_modules/@sapphire/timestamp/dist/esm/index.mjs
95
- var __defProp2, __defNormalProp, __name, __publicField, days, months, tokens, tokenResolvers, _Timestamp, Timestamp;
96
- var init_esm = __esm({
97
- "node_modules/@sapphire/timestamp/dist/esm/index.mjs"() {
98
- "use strict";
99
- __defProp2 = Object.defineProperty;
100
- __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
101
- __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
102
- __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
103
- days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
104
- months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
105
- tokens = /* @__PURE__ */ new Map([
106
- ["Y", 4],
107
- ["Q", 1],
108
- ["M", 4],
109
- ["D", 4],
110
- ["d", 4],
111
- ["X", 1],
112
- ["x", 1],
113
- ["H", 2],
114
- ["h", 2],
115
- ["a", 1],
116
- ["A", 1],
117
- ["m", 2],
118
- ["s", 2],
119
- ["S", 3],
120
- ["Z", 2],
121
- ["l", 4],
122
- ["L", 4],
123
- ["T", 1],
124
- ["t", 1]
125
- ]);
126
- tokenResolvers = /* @__PURE__ */ new Map([
127
- // Dates
128
- ["Y", (time) => String(time.getFullYear()).slice(2)],
129
- ["YY", (time) => String(time.getFullYear()).slice(2)],
130
- ["YYY", (time) => String(time.getFullYear())],
131
- ["YYYY", (time) => String(time.getFullYear())],
132
- ["Q", (time) => String((time.getMonth() + 1) / 3)],
133
- ["M", (time) => String(time.getMonth() + 1)],
134
- ["MM", (time) => String(time.getMonth() + 1).padStart(2, "0")],
135
- ["MMM", (time) => months[time.getMonth()]],
136
- ["MMMM", (time) => months[time.getMonth()]],
137
- ["D", (time) => String(time.getDate())],
138
- ["DD", (time) => String(time.getDate()).padStart(2, "0")],
139
- ["DDD", (time) => String(Math.floor(
140
- (time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5
141
- /* Day */
142
- ))],
143
- ["DDDD", (time) => String(Math.floor(
144
- (time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5
145
- /* Day */
146
- ))],
147
- [
148
- "d",
149
- (time) => {
150
- const day = String(time.getDate());
151
- if (day !== "11" && day.endsWith("1")) return `${day}st`;
152
- if (day !== "12" && day.endsWith("2")) return `${day}nd`;
153
- if (day !== "13" && day.endsWith("3")) return `${day}rd`;
154
- return `${day}th`;
155
- }
156
- ],
157
- ["dd", (time) => days[time.getDay()].slice(0, 2)],
158
- ["ddd", (time) => days[time.getDay()].slice(0, 3)],
159
- ["dddd", (time) => days[time.getDay()]],
160
- ["X", (time) => String(
161
- time.valueOf() / 1e3
162
- /* Second */
163
- )],
164
- ["x", (time) => String(time.valueOf())],
165
- // Locales
166
- ["H", (time) => String(time.getHours())],
167
- ["HH", (time) => String(time.getHours()).padStart(2, "0")],
168
- ["h", (time) => String(time.getHours() % 12 || 12)],
169
- ["hh", (time) => String(time.getHours() % 12 || 12).padStart(2, "0")],
170
- ["a", (time) => time.getHours() < 12 ? "am" : "pm"],
171
- ["A", (time) => time.getHours() < 12 ? "AM" : "PM"],
172
- ["m", (time) => String(time.getMinutes())],
173
- ["mm", (time) => String(time.getMinutes()).padStart(2, "0")],
174
- ["s", (time) => String(time.getSeconds())],
175
- ["ss", (time) => String(time.getSeconds()).padStart(2, "0")],
176
- ["S", (time) => String(time.getMilliseconds())],
177
- ["SS", (time) => String(time.getMilliseconds()).padStart(2, "0")],
178
- ["SSS", (time) => String(time.getMilliseconds()).padStart(3, "0")],
179
- ["T", (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`],
180
- [
181
- "t",
182
- (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")}:${String(time.getSeconds()).padStart(2, "0")} ${time.getHours() < 12 ? "am" : "pm"}`
183
- ],
184
- ["L", (time) => `${String(time.getMonth() + 1).padStart(2, "0")}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
185
- ["l", (time) => `${String(time.getMonth() + 1)}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
186
- ["LL", (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
187
- ["ll", (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
188
- [
189
- "LLL",
190
- (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(
191
- time.getHours() % 12 || 12
192
- )}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
193
- ],
194
- [
195
- "lll",
196
- (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(
197
- time.getHours() % 12 || 12
198
- )}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
199
- ],
200
- [
201
- "LLLL",
202
- (time) => `${days[time.getDay()]}, ${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(
203
- time.getHours() % 12 || 12
204
- )}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
205
- ],
206
- [
207
- "llll",
208
- (time) => `${days[time.getDay()].slice(0, 3)} ${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(
209
- time.getFullYear()
210
- )} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
211
- ],
212
- [
213
- "Z",
214
- (time) => {
215
- const offset = time.getTimezoneOffset();
216
- const unsigned = offset >= 0;
217
- const absolute = Math.abs(offset);
218
- return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
219
- }
220
- ],
221
- [
222
- "ZZ",
223
- (time) => {
224
- const offset = time.getTimezoneOffset();
225
- const unsigned = offset >= 0;
226
- const absolute = Math.abs(offset);
227
- return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
228
- }
229
- ]
230
- ]);
231
- _Timestamp = class _Timestamp2 {
232
- /**
233
- * Starts a new Timestamp and parses the pattern.
234
- * @since 1.0.0
235
- * @param pattern The pattern to parse
236
- */
237
- constructor(pattern) {
238
- __publicField(this, "pattern");
239
- __publicField(this, "template");
240
- this.pattern = pattern;
241
- this.template = _Timestamp2.parse(pattern);
242
- }
243
- /**
244
- * Display the current date with the current pattern.
245
- * @since 1.0.0
246
- * @param time The time to display
247
- */
248
- display(time = /* @__PURE__ */ new Date()) {
249
- return _Timestamp2.display(this.template, time);
250
- }
251
- /**
252
- * Display the current date utc with the current pattern.
253
- * @since 1.0.0
254
- * @param time The time to display in utc
255
- */
256
- displayUTC(time) {
257
- return _Timestamp2.display(this.template, _Timestamp2.utc(time));
258
- }
259
- /**
260
- * Edits the current pattern.
261
- * @since 1.0.0
262
- * @param pattern The new pattern for this instance
263
- * @chainable
264
- */
265
- edit(pattern) {
266
- this.pattern = pattern;
267
- this.template = _Timestamp2.parse(pattern);
268
- return this;
269
- }
270
- /**
271
- * Defines the toString behavior of Timestamp.
272
- */
273
- toString() {
274
- return this.display();
275
- }
276
- /**
277
- * Display the current date with the current pattern.
278
- * @since 1.0.0
279
- * @param pattern The pattern to parse
280
- * @param time The time to display
281
- */
282
- static displayArbitrary(pattern, time = /* @__PURE__ */ new Date()) {
283
- return _Timestamp2.display(_Timestamp2.parse(pattern), time);
284
- }
285
- /**
286
- * Display the current date utc with the current pattern.
287
- * @since 1.0.0
288
- * @param pattern The pattern to parse
289
- * @param time The time to display
290
- */
291
- static displayUTCArbitrary(pattern, time = /* @__PURE__ */ new Date()) {
292
- return _Timestamp2.display(_Timestamp2.parse(pattern), _Timestamp2.utc(time));
293
- }
294
- /**
295
- * Creates a UTC Date object to work with.
296
- * @since 1.0.0
297
- * @param time The date to convert to utc
298
- */
299
- static utc(time = /* @__PURE__ */ new Date()) {
300
- time = _Timestamp2.resolveDate(time);
301
- return new Date(time.valueOf() + time.getTimezoneOffset() * 6e4);
302
- }
303
- /**
304
- * Display the current date with the current pattern.
305
- * @since 1.0.0
306
- * @param template The pattern to parse
307
- * @param time The time to display
308
- */
309
- static display(template, time) {
310
- let output = "";
311
- const parsedTime = _Timestamp2.resolveDate(time);
312
- for (const { content, type } of template) output += content || tokenResolvers.get(type)(parsedTime);
313
- return output;
314
- }
315
- /**
316
- * Parses the pattern.
317
- * @since 1.0.0
318
- * @param pattern The pattern to parse
319
- */
320
- static parse(pattern) {
321
- const template = [];
322
- for (let i = 0; i < pattern.length; i++) {
323
- let current = "";
324
- const currentChar = pattern[i];
325
- const tokenMax = tokens.get(currentChar);
326
- if (typeof tokenMax === "number") {
327
- current += currentChar;
328
- while (pattern[i + 1] === currentChar && current.length < tokenMax) current += pattern[++i];
329
- template.push({ type: current, content: null });
330
- } else if (currentChar === "[") {
331
- while (i + 1 < pattern.length && pattern[i + 1] !== "]") current += pattern[++i];
332
- i++;
333
- template.push({ type: "literal", content: current || "[" });
334
- } else {
335
- current += currentChar;
336
- while (i + 1 < pattern.length && !tokens.has(pattern[i + 1]) && pattern[i + 1] !== "[") current += pattern[++i];
337
- template.push({ type: "literal", content: current });
338
- }
339
- }
340
- return template;
341
- }
342
- /**
343
- * Resolves a date.
344
- * @since 1.0.0
345
- * @param time The time to parse
346
- */
347
- static resolveDate(time) {
348
- return time instanceof Date ? time : new Date(time);
349
- }
350
- };
351
- __name(_Timestamp, "Timestamp");
352
- Timestamp = _Timestamp;
353
- }
354
- });
355
-
356
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/logger/ILogger.ts
357
- var LogLevel;
358
- var init_ILogger = __esm({
359
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/logger/ILogger.ts"() {
360
- "use strict";
361
- LogLevel = /* @__PURE__ */ (function(LogLevel2) {
362
- LogLevel2[LogLevel2["Trace"] = 10] = "Trace";
363
- LogLevel2[LogLevel2["Debug"] = 20] = "Debug";
364
- LogLevel2[LogLevel2["Info"] = 30] = "Info";
365
- LogLevel2[LogLevel2["Warn"] = 40] = "Warn";
366
- LogLevel2[LogLevel2["Error"] = 50] = "Error";
367
- LogLevel2[LogLevel2["Fatal"] = 60] = "Fatal";
368
- LogLevel2[LogLevel2["None"] = 100] = "None";
369
- return LogLevel2;
370
- })({});
371
- }
372
- });
373
-
374
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/logger/Logger.ts
375
- var import_console, import_util, colorette, Logger, LoggerStyle, LoggerTimestamp, LoggerLevel, Logger_default, LoggerStyleEffect, LoggerStyleText, LoggerStyleBackground, I18nLoggerAdapter;
376
- var init_Logger = __esm({
377
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/logger/Logger.ts"() {
378
- "use strict";
379
- import_console = require("console");
380
- import_util = require("util");
381
- colorette = __toESM(require("colorette"));
382
- init_esm();
383
- init_ILogger();
384
- init_ILogger();
385
- Logger = class _Logger {
386
- level;
387
- formats;
388
- join;
389
- depth;
390
- console;
391
- static instance = null;
392
- static LOG_METHODS = /* @__PURE__ */ new Map([
393
- [LogLevel.Trace, "trace"],
394
- [LogLevel.Debug, "debug"],
395
- [LogLevel.Info, "info"],
396
- [LogLevel.Warn, "warn"],
397
- [LogLevel.Error, "error"],
398
- [LogLevel.Fatal, "error"]
399
- ]);
400
- static DEFAULT_COLORS = /* @__PURE__ */ new Map([
401
- [LogLevel.Trace, colorette.gray],
402
- [LogLevel.Debug, colorette.magenta],
403
- [LogLevel.Info, colorette.cyan],
404
- [LogLevel.Warn, colorette.yellow],
405
- [LogLevel.Error, colorette.red],
406
- [LogLevel.Fatal, colorette.bgRed],
407
- [LogLevel.None, colorette.white]
408
- ]);
409
- static DEFAULT_NAMES = /* @__PURE__ */ new Map([
410
- [LogLevel.Trace, "TRACE"],
411
- [LogLevel.Debug, "DEBUG"],
412
- [LogLevel.Info, "INFO"],
413
- [LogLevel.Warn, "WARN"],
414
- [LogLevel.Error, "ERROR"],
415
- [LogLevel.Fatal, "FATAL"],
416
- [LogLevel.None, ""]
417
- ]);
418
- constructor(options = {}) {
419
- this.level = options.level ?? LogLevel.Info;
420
- this.console = new import_console.Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);
421
- this.formats = this.createFormatMap(options.format, options.defaultFormat ?? options.format?.none ?? {});
422
- this.join = options.join ?? " ";
423
- this.depth = options.depth ?? 2;
424
- }
425
- static getInstance() {
426
- if (!this.instance) {
427
- this.instance = new _Logger();
428
- }
429
- return this.instance;
430
- }
431
- static get stylize() {
432
- return colorette.isColorSupported;
433
- }
434
- setLevel(level) {
435
- this.level = level;
436
- }
437
- has(level) {
438
- return level >= this.level;
439
- }
440
- trace(...values) {
441
- this.write(LogLevel.Trace, ...values);
442
- }
443
- debug(...values) {
444
- this.write(LogLevel.Debug, ...values);
445
- }
446
- info(...values) {
447
- this.write(LogLevel.Info, ...values);
448
- }
449
- log(...values) {
450
- this.write(LogLevel.Info, ...values);
451
- }
452
- warn(...values) {
453
- this.write(LogLevel.Warn, ...values);
454
- }
455
- error(...values) {
456
- this.write(LogLevel.Error, ...values);
457
- }
458
- fatal(...values) {
459
- this.write(LogLevel.Fatal, ...values);
460
- }
461
- write(level, ...values) {
462
- if (level < this.level) return;
463
- const method = _Logger.LOG_METHODS.get(level);
464
- const formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None);
465
- const message = formatter.run(this.preprocess(values));
466
- switch (method) {
467
- case "trace":
468
- this.console.trace(message);
469
- break;
470
- case "debug":
471
- this.console.debug(message);
472
- break;
473
- case "info":
474
- this.console.info(message);
475
- break;
476
- case "warn":
477
- this.console.warn(message);
478
- break;
479
- case "error":
480
- this.console.error(message);
481
- break;
482
- default:
483
- this.console.log(message);
484
- }
485
- }
486
- preprocess(values) {
487
- const inspectOptions = {
488
- colors: colorette.isColorSupported,
489
- depth: this.depth
490
- };
491
- return values.map((value) => typeof value === "string" ? value : (0, import_util.inspect)(value, inspectOptions)).join(this.join);
492
- }
493
- createFormatMap(options = {}, defaults) {
494
- const map = /* @__PURE__ */ new Map();
495
- for (const [level, color] of _Logger.DEFAULT_COLORS) {
496
- const name = _Logger.DEFAULT_NAMES.get(level);
497
- const levelOptions = options[this.getLevelKey(level)] ?? this.createDefaultLevel(defaults, color, name ?? "");
498
- map.set(level, levelOptions instanceof LoggerLevel ? levelOptions : new LoggerLevel(levelOptions));
499
- }
500
- return map;
501
- }
502
- createDefaultLevel(defaults, color, name) {
503
- return new LoggerLevel({
504
- ...defaults,
505
- timestamp: defaults.timestamp === null ? null : {
506
- ...defaults.timestamp,
507
- color
508
- },
509
- infix: name.length ? `${color(name.padEnd(5, " "))} ` : ""
510
- });
511
- }
512
- getLevelKey(level) {
513
- const keys = {
514
- [LogLevel.Trace]: "trace",
515
- [LogLevel.Debug]: "debug",
516
- [LogLevel.Info]: "info",
517
- [LogLevel.Warn]: "warn",
518
- [LogLevel.Error]: "error",
519
- [LogLevel.Fatal]: "fatal",
520
- [LogLevel.None]: "none"
521
- };
522
- return keys[level];
523
- }
524
- };
525
- LoggerStyle = class {
526
- style;
527
- constructor(resolvable = {}) {
528
- if (typeof resolvable === "function") {
529
- this.style = resolvable;
530
- } else {
531
- const styles = this.buildStyleArray(resolvable);
532
- this.style = this.combineStyles(styles);
533
- }
534
- }
535
- run(value) {
536
- return this.style(String(value));
537
- }
538
- buildStyleArray(options) {
539
- const styles = [];
540
- if (options.effects) {
541
- styles.push(...options.effects.map((effect) => colorette[effect]));
542
- }
543
- if (options.text) {
544
- styles.push(colorette[options.text]);
545
- }
546
- if (options.background) {
547
- styles.push(colorette[options.background]);
548
- }
549
- return styles;
550
- }
551
- combineStyles(styles) {
552
- if (styles.length === 0) return colorette.reset;
553
- if (styles.length === 1) return styles[0];
554
- return ((text) => styles.reduce((result, style) => style(result), text));
555
- }
556
- };
557
- LoggerTimestamp = class {
558
- timestamp;
559
- utc;
560
- color;
561
- formatter;
562
- constructor(options = {}) {
563
- this.timestamp = new Timestamp(options.pattern ?? "YYYY-MM-DD HH:mm:ss");
564
- this.utc = options.utc ?? false;
565
- this.color = options.color === null ? null : new LoggerStyle(options.color);
566
- this.formatter = options.formatter ?? ((timestamp) => `${timestamp} `);
567
- }
568
- run() {
569
- const date = /* @__PURE__ */ new Date();
570
- const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);
571
- return this.formatter(this.color ? this.color.run(result) : result);
572
- }
573
- };
574
- LoggerLevel = class {
575
- timestamp;
576
- infix;
577
- message;
578
- constructor(options = {}) {
579
- this.timestamp = options.timestamp === null ? null : new LoggerTimestamp(options.timestamp);
580
- this.infix = options.infix ?? "";
581
- this.message = options.message === null ? null : new LoggerStyle(options.message);
582
- }
583
- run(content) {
584
- const prefix = (this.timestamp?.run() ?? "") + this.infix;
585
- if (prefix.length) {
586
- const formatter = this.message ? (line) => prefix + this.message?.run(line) : (line) => prefix + line;
587
- return content.split("\n").map(formatter).join("\n");
588
- }
589
- return this.message ? this.message.run(content) : content;
590
- }
591
- };
592
- Logger_default = Logger.getInstance();
593
- LoggerStyleEffect = /* @__PURE__ */ (function(LoggerStyleEffect2) {
594
- LoggerStyleEffect2["Reset"] = "reset";
595
- LoggerStyleEffect2["Bold"] = "bold";
596
- LoggerStyleEffect2["Dim"] = "dim";
597
- LoggerStyleEffect2["Italic"] = "italic";
598
- LoggerStyleEffect2["Underline"] = "underline";
599
- LoggerStyleEffect2["Inverse"] = "inverse";
600
- LoggerStyleEffect2["Hidden"] = "hidden";
601
- LoggerStyleEffect2["Strikethrough"] = "strikethrough";
602
- return LoggerStyleEffect2;
603
- })({});
604
- LoggerStyleText = /* @__PURE__ */ (function(LoggerStyleText2) {
605
- LoggerStyleText2["Black"] = "black";
606
- LoggerStyleText2["Red"] = "red";
607
- LoggerStyleText2["Green"] = "green";
608
- LoggerStyleText2["Yellow"] = "yellow";
609
- LoggerStyleText2["Blue"] = "blue";
610
- LoggerStyleText2["Magenta"] = "magenta";
611
- LoggerStyleText2["Cyan"] = "cyan";
612
- LoggerStyleText2["White"] = "white";
613
- LoggerStyleText2["Gray"] = "gray";
614
- LoggerStyleText2["BlackBright"] = "blackBright";
615
- LoggerStyleText2["RedBright"] = "redBright";
616
- LoggerStyleText2["GreenBright"] = "greenBright";
617
- LoggerStyleText2["YellowBright"] = "yellowBright";
618
- LoggerStyleText2["BlueBright"] = "blueBright";
619
- LoggerStyleText2["MagentaBright"] = "magentaBright";
620
- LoggerStyleText2["CyanBright"] = "cyanBright";
621
- LoggerStyleText2["WhiteBright"] = "whiteBright";
622
- return LoggerStyleText2;
623
- })({});
624
- LoggerStyleBackground = /* @__PURE__ */ (function(LoggerStyleBackground2) {
625
- LoggerStyleBackground2["Black"] = "bgBlack";
626
- LoggerStyleBackground2["Red"] = "bgRed";
627
- LoggerStyleBackground2["Green"] = "bgGreen";
628
- LoggerStyleBackground2["Yellow"] = "bgYellow";
629
- LoggerStyleBackground2["Blue"] = "bgBlue";
630
- LoggerStyleBackground2["Magenta"] = "bgMagenta";
631
- LoggerStyleBackground2["Cyan"] = "bgCyan";
632
- LoggerStyleBackground2["White"] = "bgWhite";
633
- LoggerStyleBackground2["BlackBright"] = "bgBlackBright";
634
- LoggerStyleBackground2["RedBright"] = "bgRedBright";
635
- LoggerStyleBackground2["GreenBright"] = "bgGreenBright";
636
- LoggerStyleBackground2["YellowBright"] = "bgYellowBright";
637
- LoggerStyleBackground2["BlueBright"] = "bgBlueBright";
638
- LoggerStyleBackground2["MagentaBright"] = "bgMagentaBright";
639
- LoggerStyleBackground2["CyanBright"] = "bgCyanBright";
640
- LoggerStyleBackground2["WhiteBright"] = "bgWhiteBright";
641
- return LoggerStyleBackground2;
642
- })({});
643
- I18nLoggerAdapter = class {
644
- type = "logger";
645
- constructor(logger) {
646
- this.logger = logger;
647
- }
648
- log(...args) {
649
- this.logger.debug("[i18next]", ...args);
650
- }
651
- warn(...args) {
652
- this.logger.warn("[i18next]", ...args);
653
- }
654
- error(...args) {
655
- this.logger.error("[i18next]", ...args);
656
- }
657
- };
658
- }
659
- });
660
-
661
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/index.ts
662
- var init_utils = __esm({
663
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/index.ts"() {
664
- "use strict";
665
- init_util();
666
- init_Files();
667
- init_Logger();
668
- }
669
- });
670
-
671
- // unplugin-oxc:/home/runner/work/framework/framework/src/context.ts
672
- function setClient(client) {
673
- currentClient = client;
674
- }
675
- function clearClient() {
676
- currentClient = null;
677
- }
678
- var currentClient;
679
- var init_context = __esm({
680
- "unplugin-oxc:/home/runner/work/framework/framework/src/context.ts"() {
681
- "use strict";
682
- currentClient = null;
683
- }
684
- });
685
-
686
- // src/events/ready.ts
687
- var require_ready = __commonJS({
688
- "src/events/ready.ts"() {
689
- "use strict";
690
- var import_discord4 = require("discord.js");
691
- init_structures();
692
- new EventBuilder(import_discord4.Events.ClientReady).onExecute(async function(context) {
693
- if (context.client.options.autoRegisterCommands) {
694
- await context.client.registerCommands();
695
- }
696
- });
697
- }
698
- });
699
-
700
- // src/events/interaction.ts
701
- var require_interaction = __commonJS({
702
- "src/events/interaction.ts"() {
703
- "use strict";
704
- var import_discord4 = require("discord.js");
705
- init_structures();
706
- new EventBuilder(import_discord4.Events.InteractionCreate, false).onExecute(async function(context, interaction) {
707
- if (!interaction.isChatInputCommand()) return;
708
- const command = context.client.commands.get(interaction.commandName);
709
- const ctx = new Context(context.client, { interaction });
710
- if (!command) {
711
- await interaction.reply({
712
- content: ctx.t("error.command.notfound", { defaultValue: "Command not found or disabled." }),
713
- flags: import_discord4.MessageFlags.Ephemeral
714
- });
715
- return;
716
- }
717
- if (!command.supportsSlash) {
718
- await interaction.reply({
719
- content: ctx.t("error.command.disabled", { defaultValue: "Command not found or disabled." }),
720
- flags: import_discord4.MessageFlags.Ephemeral
721
- });
722
- return;
723
- }
724
- try {
725
- ctx.locale = interaction.locale;
726
- context.logger.debug(`${ctx.author?.tag ?? "Unknown"} used ${command.data.name}(interaction)`);
727
- if (command._onInteraction) await command._onInteraction(ctx.toJSON());
728
- } catch (error) {
729
- context.client.logger.error(`Error executing command ${command.data.name}:`, error);
730
- if (interaction.replied || interaction.deferred) {
731
- await interaction.followUp({
732
- content: "There was an error while executing this command!",
733
- flags: import_discord4.MessageFlags.Ephemeral
734
- });
735
- } else {
736
- await interaction.reply({
737
- content: "There was an error while executing this command!",
738
- flags: import_discord4.MessageFlags.Ephemeral
739
- });
740
- }
741
- }
742
- });
743
- }
744
- });
745
-
746
- // src/events/message.ts
747
- var require_message = __commonJS({
748
- "src/events/message.ts"() {
749
- "use strict";
750
- var import_discord4 = require("discord.js");
751
- init_structures();
752
- init_utils();
753
- new EventBuilder(import_discord4.Events.MessageCreate, false, async function(context, message) {
754
- if (message.author.bot) return;
755
- const prefix = context.client.prefix;
756
- if (typeof prefix !== "string" || prefix.length === 0 || !message.content.startsWith(prefix)) return;
757
- const args = message.content.slice(prefix.length).trim().split(/ +/);
758
- const commandName = args.shift()?.toLowerCase();
759
- if (!commandName) return;
760
- const commandAlias = context.client.aliases.findKey((cmd) => cmd.has(commandName));
761
- const ctx = new Context(context.client, {
762
- message,
763
- args
764
- });
765
- let command = context.client.commands.get(commandAlias ?? commandName);
766
- if (!command) {
767
- await message.reply({
768
- content: ctx.t("error.command.notfound", { defaultValue: "Command not found or disabled." }),
769
- allowedMentions: { repliedUser: false }
770
- }).then(deleteMessageAfterSent);
771
- return;
772
- }
773
- if (!command.supportsPrefix) {
774
- await message.reply({
775
- content: ctx.t("error.command.disabled", { defaultValue: "Command not found or disabled." }),
776
- allowedMentions: { repliedUser: false }
777
- }).then(deleteMessageAfterSent);
778
- return;
779
- }
780
- try {
781
- context.logger.debug(`${ctx.author?.tag ?? "Unknown"} used ${command.data.name}(message)`);
782
- if (command._onMessage) await command._onMessage(ctx.toJSON());
783
- } catch (error) {
784
- context.client.logger.error(`Error executing command ${command.data.name}:`, error);
785
- }
786
- });
787
- }
788
- });
789
-
790
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/core/Client.ts
791
- var import_discord, import_path2, import_fs, defaultOpts, Client;
792
- var init_Client = __esm({
793
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/core/Client.ts"() {
794
- "use strict";
795
- import_discord = require("discord.js");
796
- import_path2 = __toESM(require("path"));
797
- init_utils();
798
- init_context();
799
- import_fs = require("fs");
800
- defaultOpts = {
801
- includePaths: ["events", "commands"],
802
- autoRegisterCommands: true
803
- };
804
- Client = class extends import_discord.Client {
805
- logger;
806
- commands;
807
- aliases;
808
- prefix;
809
- i18n;
810
- constructor(opts) {
811
- super({
812
- ...defaultOpts,
813
- ...opts
814
- });
815
- this.logger = new Logger(opts.logger);
816
- this.commands = new import_discord.Collection();
817
- this.aliases = new import_discord.Collection();
818
- this.prefix = getPrefix(this.options.prefix ?? { enabled: false });
819
- if (this.options.i18n) {
820
- this.i18n = this.options.i18n;
821
- this.i18n.use(new I18nLoggerAdapter(this.logger));
822
- }
823
- setClient(this);
824
- try {
825
- require_ready();
826
- require_interaction();
827
- if (this.prefix) require_message();
828
- } finally {
829
- clearClient();
830
- }
831
- }
832
- async login(token) {
833
- if (this.options.includePaths) {
834
- for (const p of this.options.includePaths) {
835
- await this.#loadDir(import_path2.default.join(getProjectRoot(), p)).catch((error) => this.logger.error(`Error loading ${p}:`, error));
836
- }
837
- }
838
- if (this.i18n && !this.i18n.isInitialized) {
839
- await this.i18n.init();
840
- }
841
- return super.login(token);
842
- }
843
- async #loadDir(dir) {
844
- if (!(0, import_fs.existsSync)(dir)) {
845
- this.logger.debug(`Directory not found: ${dir}`);
846
- return;
847
- }
848
- const files = getFiles(dir);
849
- for (const file of files) {
850
- await this.#loadFile(file);
851
- }
852
- }
853
- async #loadFile(file) {
854
- try {
855
- delete require.cache[require.resolve(file)];
856
- setClient(this);
857
- require(file);
858
- } catch (error) {
859
- this.logger.error(`Error loading file ${file}:`, error);
860
- } finally {
861
- clearClient();
862
- }
863
- }
864
- async registerCommands() {
865
- if (!this.token) {
866
- this.logger.warn("registerCommands skipped: client token is not set.");
867
- return;
868
- }
869
- if (!this.application) {
870
- this.logger.warn("registerCommands skipped: client application is not ready.");
871
- return;
872
- }
873
- const slashCommands = this.commands.filter((cmd) => cmd.supportsSlash).map((cmd) => cmd.data.toClientJSON(this));
874
- const rest = new import_discord.REST({ version: "10" }).setToken(this.token);
875
- try {
876
- this.logger.debug(`Started refreshing ${slashCommands.length} application (/) commands.`);
877
- await rest.put(import_discord.Routes.applicationCommands(this.application.id), { body: slashCommands });
878
- this.logger.info(`Loaded ${slashCommands.length} application (/) commands.`);
879
- } catch (error) {
880
- this.logger.error("Failed to register commands:", error);
881
- }
882
- }
883
- };
884
- }
885
- });
886
-
887
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/core/index.ts
888
- var init_core = __esm({
889
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/core/index.ts"() {
890
- "use strict";
891
- init_Client();
892
- }
893
- });
894
-
895
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Command.ts
896
- var CommandBuilder;
897
- var init_Command = __esm({
898
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Command.ts"() {
899
- "use strict";
900
- init_context();
901
- CommandBuilder = class {
902
- client;
903
- logger;
904
- #supportsSlash;
905
- #supportsPrefix;
906
- _onMessage;
907
- _onInteraction;
908
- get supportsSlash() {
909
- return this.#supportsSlash && this._onInteraction;
910
- }
911
- get supportsPrefix() {
912
- return this.#supportsPrefix && this._onMessage;
913
- }
914
- constructor(data) {
915
- this.data = data;
916
- const client = currentClient;
917
- if (!client) throw new Error("Client is not defined");
918
- this.client = client;
919
- this.logger = client.logger;
920
- let commandJSON = data.toJSON();
921
- this.#supportsPrefix = commandJSON.prefix_support ?? false;
922
- this.#supportsSlash = commandJSON.slash_support ?? false;
923
- if (!this.#supportsPrefix && !this.#supportsSlash) {
924
- throw new Error(`Command ${data.name} must support either slash or prefix commands.`);
925
- }
926
- if (this.client.commands.has(data.name)) throw new Error(`Command name "${data.name}" is already registered.`);
927
- const existingAliasOwner = this.client.aliases.findKey((aliases) => aliases.has(data.name));
928
- if (existingAliasOwner) {
929
- throw new Error(`Command name "${data.name}" is already registered as an alias for command "${existingAliasOwner}".`);
930
- }
931
- for (const alias of commandJSON.aliases) {
932
- if (this.client.commands.has(alias)) {
933
- throw new Error(`Alias "${alias}" is already registered as a command name.`);
934
- }
935
- const conflictingCommand = this.client.aliases.findKey((aliases) => aliases.has(alias));
936
- if (conflictingCommand) {
937
- throw new Error(`Alias "${alias}" is already registered as an alias for command "${conflictingCommand}".`);
938
- }
939
- }
940
- this.client.commands.set(commandJSON.name, this);
941
- if (commandJSON.aliases.length > 0) {
942
- this.client.aliases.set(commandJSON.name, new Set(commandJSON.aliases));
943
- }
944
- this.logger.debug(`Loaded Command ${commandJSON.name}`);
945
- }
946
- onMessage(func) {
947
- this._onMessage = func;
948
- return this;
949
- }
950
- onInteraction(func) {
951
- this._onInteraction = func;
952
- return this;
953
- }
954
- };
955
- }
956
- });
957
-
958
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Context.ts
959
- var import_discord2, Context;
960
- var init_Context = __esm({
961
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Context.ts"() {
962
- "use strict";
963
- import_discord2 = require("discord.js");
964
- Context = class {
965
- args;
966
- data;
967
- locale;
968
- constructor(client, payload) {
969
- this.client = client;
970
- this.args = payload.args ?? [];
971
- if ("interaction" in payload) {
972
- this.data = payload.interaction;
973
- } else {
974
- this.data = payload.message;
975
- }
976
- }
977
- isInteraction() {
978
- return this.data instanceof import_discord2.ChatInputCommandInteraction;
979
- }
980
- isMessage() {
981
- return this.data instanceof import_discord2.Message;
982
- }
983
- get author() {
984
- if (this.isInteraction()) {
985
- return this.data.user;
986
- }
987
- if (this.isMessage()) {
988
- return this.data.author;
989
- }
990
- return null;
991
- }
992
- t(key, options) {
993
- if (!this.client.i18n) {
994
- throw new Error("i18n is not initialized");
995
- }
996
- const locale = this.locale ?? (Array.isArray(this.client.i18n.options.fallbackLng) ? this.client.i18n.options.fallbackLng[0] : this.client.i18n.options.fallbackLng) ?? "en";
997
- const t = this.client.i18n.getFixedT(locale);
998
- const result = t(key, options);
999
- if (result === key && options?.defaultValue) {
1000
- return options.defaultValue;
1001
- }
1002
- return result;
1003
- }
1004
- toJSON() {
1005
- const { data, args, author } = this;
1006
- if (this.isInteraction()) {
1007
- return {
1008
- kind: "interaction",
1009
- interaction: data,
1010
- author,
1011
- t: this.t.bind(this)
1012
- };
1013
- }
1014
- return {
1015
- kind: "message",
1016
- message: data,
1017
- args,
1018
- author,
1019
- t: this.t.bind(this)
1020
- };
1021
- }
1022
- };
1023
- }
1024
- });
1025
-
1026
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Event.ts
1027
- var EventBuilder;
1028
- var init_Event = __esm({
1029
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Event.ts"() {
1030
- "use strict";
1031
- init_context();
1032
- EventBuilder = class {
1033
- client;
1034
- logger;
1035
- #handler;
1036
- #bound = false;
1037
- #listener = async (...args) => {
1038
- if (!this.#handler) return;
1039
- try {
1040
- await this.#handler(this, ...args);
1041
- } catch (error) {
1042
- this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`, error);
1043
- }
1044
- };
1045
- constructor(name, once = false, _handler) {
1046
- this.name = name;
1047
- this.once = once;
1048
- if (!currentClient) throw new Error("Client is not defined");
1049
- this.client = currentClient;
1050
- this.logger = currentClient.logger;
1051
- if (_handler) {
1052
- this.#handler = _handler;
1053
- this.#register();
1054
- }
1055
- }
1056
- #register() {
1057
- if (this.#bound || !this.#handler) return;
1058
- if (this.once) {
1059
- this.client.once(this.name, this.#listener);
1060
- } else {
1061
- this.client.on(this.name, this.#listener);
1062
- }
1063
- this.#bound = true;
1064
- this.logger.debug(`Loaded Event ${String(this.name)}`);
1065
- }
1066
- onExecute(func) {
1067
- this.#handler = func;
1068
- this.#register();
1069
- return this;
1070
- }
1071
- };
1072
- }
1073
- });
1074
-
1075
- // unplugin-oxc:/home/runner/work/framework/framework/src/utils/normalizeArray.ts
1076
- function normalizeArray(arr) {
1077
- if (Array.isArray(arr[0])) return [...arr[0]];
1078
- return arr;
1079
- }
1080
- var init_normalizeArray = __esm({
1081
- "unplugin-oxc:/home/runner/work/framework/framework/src/utils/normalizeArray.ts"() {
1082
- "use strict";
1083
- }
1084
- });
1085
-
1086
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Builder.ts
1087
- var import_discord3, ApplicationCommandBuilder;
1088
- var init_Builder = __esm({
1089
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/Builder.ts"() {
1090
- "use strict";
1091
- import_discord3 = require("discord.js");
1092
- init_normalizeArray();
1093
- ApplicationCommandBuilder = class extends import_discord3.SlashCommandBuilder {
1094
- constructor() {
1095
- super();
1096
- }
1097
- prefix_support = true;
1098
- slash_support = true;
1099
- aliases = [];
1100
- setAliases(...alias) {
1101
- Reflect.set(this, "aliases", normalizeArray(alias));
1102
- return this;
1103
- }
1104
- addAliases(...alias) {
1105
- const currentAliases = Reflect.get(this, "aliases") || [];
1106
- Reflect.set(this, "aliases", normalizeArray([...currentAliases, ...normalizeArray(alias)]));
1107
- return this;
1108
- }
1109
- setPrefixSupport(support) {
1110
- Reflect.set(this, "prefix_support", support);
1111
- return this;
1112
- }
1113
- setSlashSupport(support) {
1114
- Reflect.set(this, "slash_support", support);
1115
- return this;
1116
- }
1117
- toJSON() {
1118
- return super.toJSON();
1119
- }
1120
- toClientJSON(_client) {
1121
- return { ...this.toJSON() };
1122
- }
1123
- };
1124
- }
1125
- });
1126
-
1127
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/index.ts
1128
- var init_builder = __esm({
1129
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/builder/index.ts"() {
1130
- "use strict";
1131
- init_Command();
1132
- init_Context();
1133
- init_Event();
1134
- init_Builder();
1135
- }
1136
- });
1137
-
1138
- // unplugin-oxc:/home/runner/work/framework/framework/src/structures/index.ts
1139
- var init_structures = __esm({
1140
- "unplugin-oxc:/home/runner/work/framework/framework/src/structures/index.ts"() {
1141
- "use strict";
1142
- init_core();
1143
- init_builder();
1144
- }
1145
- });
1146
-
1147
- // unplugin-oxc:/home/runner/work/framework/framework/src/index.ts
1148
- var index_exports = {};
1149
- __export(index_exports, {
1150
- ApplicationCommandBuilder: () => ApplicationCommandBuilder,
1151
- Client: () => Client,
1152
- CommandBuilder: () => CommandBuilder,
1153
- Context: () => Context,
1154
- EventBuilder: () => EventBuilder,
1155
- I18nLoggerAdapter: () => I18nLoggerAdapter,
1156
- LogLevel: () => LogLevel,
1157
- Logger: () => Logger,
1158
- LoggerLevel: () => LoggerLevel,
1159
- LoggerStyle: () => LoggerStyle,
1160
- LoggerStyleBackground: () => LoggerStyleBackground,
1161
- LoggerStyleEffect: () => LoggerStyleEffect,
1162
- LoggerStyleText: () => LoggerStyleText,
1163
- LoggerTimestamp: () => LoggerTimestamp,
1164
- clearClient: () => clearClient,
1165
- currentClient: () => currentClient,
1166
- setClient: () => setClient,
1167
- version: () => version
1168
- });
1169
- module.exports = __toCommonJS(index_exports);
1170
- init_structures();
1171
- init_Logger();
1172
- init_context();
1173
- var version = "v0.1.2-beta.1";
1174
- // Annotate the CommonJS export names for ESM import in node:
1175
- 0 && (module.exports = {
1176
- ApplicationCommandBuilder,
1177
- Client,
1178
- CommandBuilder,
1179
- Context,
1180
- EventBuilder,
1181
- I18nLoggerAdapter,
1182
- LogLevel,
1183
- Logger,
1184
- LoggerLevel,
1185
- LoggerStyle,
1186
- LoggerStyleBackground,
1187
- LoggerStyleEffect,
1188
- LoggerStyleText,
1189
- LoggerTimestamp,
1190
- clearClient,
1191
- currentClient,
1192
- setClient,
1193
- version
1194
- });
1
+ var nt=Object.defineProperty;var D=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var l=(e,t)=>()=>(e&&(t=e(e=0)),t);var B=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})};import{Locale as I}from"discord.js";function N(e,t=15e3){return new Promise(r=>{setTimeout(()=>{e.delete().catch(()=>{}),r()},t)})}function O(e){if(e&&ot.has(e))return e}function v(e){return e.isInteraction()?O(e.data.locale)??O(e.data.guildLocale)??I.EnglishUS:e.isMessage()?O(e.data.guild?.preferredLocale)??I.EnglishUS:I.EnglishUS}var at,ot,k=l(()=>{"use strict";at=["id","en-US","en-GB","bg","zh-CN","zh-TW","hr","cs","da","nl","fi","fr","de","el","hi","hu","it","ja","ko","lt","no","pl","pt-BR","ro","ru","es-ES","es-419","sv-SE","th","tr","uk","vi"],ot=new Set(at)});import lt from"fast-glob";import{existsSync as ht}from"node:fs";import m from"path";function U(e){return lt.sync(["**/*.ts","**/*.js","**/*.cjs","**/*.mjs"],{cwd:e,absolute:!0,ignore:["**/*.d.ts","node_modules/**",".git/**","dist/**","lib/**","out/**","build/**",".next/**","coverage/**"]})}function j(){let e=[];e.push(m.resolve(process.cwd()));let t=typeof D<"u"?D.main?.filename:void 0;t&&e.push(m.dirname(m.resolve(t))),typeof module<"u"&&module.parent?.filename&&e.push(m.dirname(m.resolve(module.parent.filename)));for(let r of e){let i=ct(r);if(i)return i}return e[0]}function ct(e){let t=m.resolve(e);for(;;){let r=m.join(t,"package.json");if(ht(r))return m.normalize(t);let i=m.dirname(t);if(i===t)return null;t=i}}var G=l(()=>{"use strict"});var s,_=l(()=>{"use strict";s=(function(e){return e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.None=100]="None",e})({})});import{Console as ut}from"console";import{inspect as mt}from"util";import*as a from"colorette";import{Timestamp as ft}from"@sapphire/timestamp";var E,M,R,w,Yt,Tt,zt,Vt,C,S=l(()=>{"use strict";_();_();E=class e{level;formats;join;depth;console;static instance=null;static LOG_METHODS=new Map([[s.Trace,"trace"],[s.Debug,"debug"],[s.Info,"info"],[s.Warn,"warn"],[s.Error,"error"],[s.Fatal,"error"]]);static DEFAULT_COLORS=new Map([[s.Trace,a.gray],[s.Debug,a.magenta],[s.Info,a.cyan],[s.Warn,a.yellow],[s.Error,a.red],[s.Fatal,a.bgRed],[s.None,a.white]]);static DEFAULT_NAMES=new Map([[s.Trace,"TRACE"],[s.Debug,"DEBUG"],[s.Info,"INFO"],[s.Warn,"WARN"],[s.Error,"ERROR"],[s.Fatal,"FATAL"],[s.None,""]]);constructor(t={}){this.level=t.level??s.Info,this.console=new ut(t.stdout??process.stdout,t.stderr??process.stderr),this.formats=this.createFormatMap(t.format,t.defaultFormat??t.format?.none??{}),this.join=t.join??" ",this.depth=t.depth??2}static getInstance(){return this.instance||(this.instance=new e),this.instance}static get stylize(){return a.isColorSupported}setLevel(t){this.level=t}has(t){return t>=this.level}trace(...t){this.write(s.Trace,...t)}debug(...t){this.write(s.Debug,...t)}info(...t){this.write(s.Info,...t)}log(...t){this.write(s.Info,...t)}warn(...t){this.write(s.Warn,...t)}error(...t){this.write(s.Error,...t)}fatal(...t){this.write(s.Fatal,...t)}write(t,...r){if(t<this.level)return;let i=e.LOG_METHODS.get(t),o=(this.formats.get(t)??this.formats.get(s.None)).run(this.preprocess(r));switch(i){case"trace":this.console.trace(o);break;case"debug":this.console.debug(o);break;case"info":this.console.info(o);break;case"warn":this.console.warn(o);break;case"error":this.console.error(o);break;default:this.console.log(o)}}preprocess(t){let r={colors:a.isColorSupported,depth:this.depth};return t.map(i=>typeof i=="string"?i:mt(i,r)).join(this.join)}createFormatMap(t={},r){let i=new Map;for(let[n,o]of e.DEFAULT_COLORS){let h=e.DEFAULT_NAMES.get(n),c=t[this.getLevelKey(n)]??this.createDefaultLevel(r,o,h??"");i.set(n,c instanceof w?c:new w(c))}return i}createDefaultLevel(t,r,i){return new w({...t,timestamp:t.timestamp===null?null:{...t.timestamp,color:r},infix:i.length?`${r(i.padEnd(5," "))} `:""})}getLevelKey(t){return{[s.Trace]:"trace",[s.Debug]:"debug",[s.Info]:"info",[s.Warn]:"warn",[s.Error]:"error",[s.Fatal]:"fatal",[s.None]:"none"}[t]}},M=class{style;constructor(t={}){if(typeof t=="function")this.style=t;else{let r=this.buildStyleArray(t);this.style=this.combineStyles(r)}}run(t){return this.style(String(t))}buildStyleArray(t){let r=[];return t.effects&&r.push(...t.effects.map(i=>a[i])),t.text&&r.push(a[t.text]),t.background&&r.push(a[t.background]),r}combineStyles(t){return t.length===0?a.reset:t.length===1?t[0]:(r=>t.reduce((i,n)=>n(i),r))}},R=class{timestamp;utc;color;formatter;constructor(t={}){this.timestamp=new ft(t.pattern??"YYYY-MM-DD HH:mm:ss"),this.utc=t.utc??!1,this.color=t.color===null?null:new M(t.color),this.formatter=t.formatter??(r=>`${r} `)}run(){let t=new Date,r=this.utc?this.timestamp.displayUTC(t):this.timestamp.display(t);return this.formatter(this.color?this.color.run(r):r)}},w=class{timestamp;infix;message;constructor(t={}){this.timestamp=t.timestamp===null?null:new R(t.timestamp),this.infix=t.infix??"",this.message=t.message===null?null:new M(t.message)}run(t){let r=(this.timestamp?.run()??"")+this.infix;if(r.length){let i=this.message?n=>r+this.message?.run(n):n=>r+n;return t.split(`
2
+ `).map(i).join(`
3
+ `)}return this.message?this.message.run(t):t}},Yt=E.getInstance(),Tt=(function(e){return e.Reset="reset",e.Bold="bold",e.Dim="dim",e.Italic="italic",e.Underline="underline",e.Inverse="inverse",e.Hidden="hidden",e.Strikethrough="strikethrough",e})({}),zt=(function(e){return e.Black="black",e.Red="red",e.Green="green",e.Yellow="yellow",e.Blue="blue",e.Magenta="magenta",e.Cyan="cyan",e.White="white",e.Gray="gray",e.BlackBright="blackBright",e.RedBright="redBright",e.GreenBright="greenBright",e.YellowBright="yellowBright",e.BlueBright="blueBright",e.MagentaBright="magentaBright",e.CyanBright="cyanBright",e.WhiteBright="whiteBright",e})({}),Vt=(function(e){return e.Black="bgBlack",e.Red="bgRed",e.Green="bgGreen",e.Yellow="bgYellow",e.Blue="bgBlue",e.Magenta="bgMagenta",e.Cyan="bgCyan",e.White="bgWhite",e.BlackBright="bgBlackBright",e.RedBright="bgRedBright",e.GreenBright="bgGreenBright",e.YellowBright="bgYellowBright",e.BlueBright="bgBlueBright",e.MagentaBright="bgMagentaBright",e.CyanBright="bgCyanBright",e.WhiteBright="bgWhiteBright",e})({}),C=class{type="logger";constructor(t){this.logger=t}log(...t){this.logger.debug("[i18next]",...t)}warn(...t){this.logger.warn("[i18next]",...t)}error(...t){this.logger.error("[i18next]",...t)}}});var x=l(()=>{"use strict";k();G();S()});var W={};B(W,{default:()=>pt});import{Events as dt}from"discord.js";var pt,J=l(()=>{"use strict";d();pt=new u(dt.ClientReady).onExecute(async function(e){e.client.options.autoRegisterCommands&&await e.client.registerCommands()})});var p,F,$=l(()=>{"use strict";p="Command not found or disabled.",F="There was an error while executing this command!"});var P={};B(P,{default:()=>wt});import{Events as gt,MessageFlags as y}from"discord.js";var wt,Y=l(()=>{"use strict";$();d();wt=new u(gt.InteractionCreate,!1).onExecute(async function(e,t){if(!t.isChatInputCommand())return;let r=e.client.commands.get(t.commandName),i=new f(e.client,{interaction:t});if(!r){await t.reply({content:i.t("error:command.notfound",{defaultValue:p}),flags:y.Ephemeral});return}if(!r.supportsSlash){await t.reply({content:i.t("error:command.disabled",{defaultValue:p}),flags:y.Ephemeral});return}try{e.logger.debug(`${i.author?.tag??"Unknown"} used ${r.data.name}(interaction)`),r._onInteraction&&await r._onInteraction(i.toJSON())}catch(n){e.client.logger.error(`Error executing command ${r.data.name}:`,n),t.replied||t.deferred?await t.followUp({content:F,flags:y.Ephemeral}):await t.reply({content:F,flags:y.Ephemeral})}})});var T={};B(T,{default:()=>bt});import{Events as Et}from"discord.js";var bt,z=l(()=>{"use strict";$();d();x();bt=new u(Et.MessageCreate,!1,async function(e,t){if(t.author.bot)return;let r=e.client.prefix(new f(e.client,{message:t}));if(typeof r!="string"||r.length===0||!t.content.startsWith(r))return;let i=t.content.slice(r.length).trim().split(/ +/),n=i.shift()?.toLowerCase();if(!n)return;let o=e.client.aliases.findKey(g=>g.has(n)),h=new f(e.client,{message:t,args:i}),c=e.client.commands.get(o??n);if(!c){await t.reply({content:h.t("error:command.notfound",{defaultValue:p}),allowedMentions:{repliedUser:!1}}).then(N);return}if(!c.supportsPrefix){await t.reply({content:h.t("error:command.disabled",{defaultValue:p}),allowedMentions:{repliedUser:!1}}).then(N);return}try{e.logger.debug(`${h.author?.tag??"Unknown"} used ${c.data.name}(message)`),c._onMessage&&await c._onMessage(h.toJSON())}catch(g){e.client.logger.error(`Error executing command ${c.data.name}:`,g)}})});import{Client as Mt,Collection as V,REST as Ct,Routes as xt}from"discord.js";import{existsSync as yt}from"node:fs";import H from"node:path";import{pathToFileURL as At}from"node:url";var Dt,K,q=l(()=>{"use strict";x();d();Dt={includePaths:["events","commands"],autoRegisterCommands:!0,getDefaultLang:v},K=class extends Mt{logger;commands;aliases;prefix;i18n;constructor(t){super({...Dt,...t}),this.logger=new E(t.logger),this.commands=new V,this.aliases=new V,this.prefix=this.options.prefix??(()=>!1),this.options.i18n&&(this.i18n=this.options.i18n,this.i18n.use(new C(this.logger)))}async login(t){await this.#r();for(let r of this.options.includePaths)try{let i=H.isAbsolute(r)?r:H.join(j(),r);await this.#t(i)}catch(i){this.logger.error(`Error loading ${r}:`,i)}return this.i18n&&!this.i18n.isInitialized&&await this.i18n.init(),super.login(t)}async#t(t){if(!yt(t)){this.logger.debug(`Directory not found: ${t}`);return}let r=U(t);for(let i of r)await this.#e(i)}async#r(){let t=[()=>Promise.resolve().then(()=>(J(),W)),()=>Promise.resolve().then(()=>(Y(),P))];for(let r of t){let i=await r();await this.#i(i,"[core]")}if(this.options.prefix){let r=await Promise.resolve().then(()=>(z(),T));await this.#i(r,"[core]")}}async#e(t){try{let r=At(t);r.searchParams.set("ts",Date.now().toString(36));let i=await import(r.href);await this.#i(i,t)}catch(r){this.logger.error(`Error loading file ${t}:`,r)}}async#i(t,r){let i=new Set;for(let n of Object.values(t))i.add(n);for(let n of i)await this.#s(n,r)}async#s(t,r){if(t!=null){if(Array.isArray(t)){for(let i of t)await this.#s(i,r);return}if(t instanceof b){t.attach(this);return}if(t instanceof u){t.attach(this);return}if(typeof t=="object"&&t!==null&&"attach"in t&&typeof t.attach=="function"){t.attach(this);return}if(typeof t=="function"){let i=await t(this);await this.#s(i,r);return}this.logger.debug(`Skipped unsupported export type in ${r}: ${typeof t}`)}}async registerCommands(){if(!this.token){this.logger.warn("registerCommands skipped: client token is not set.");return}if(!this.application){this.logger.warn("registerCommands skipped: client application is not ready.");return}let t=this.commands.filter(i=>i.supportsSlash).map(i=>i.data.toClientJSON(this)),r=new Ct({version:"10"}).setToken(this.token);try{this.logger.debug(`Started refreshing ${t.length} application (/) commands.`),await r.put(xt.applicationCommands(this.application.id),{body:t}),this.logger.info(`Loaded ${t.length} application (/) commands.`)}catch(i){this.logger.error("Failed to register commands:",i)}}}});var X=l(()=>{"use strict";q()});var b,Q,Z=l(()=>{"use strict";b=class{#t=null;#r=null;#e;#i;#s=!1;_onMessage;_onInteraction;get client(){if(!this.#t)throw new Error("Command is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Command is not attached to a client");return this.#r}get supportsSlash(){return this.#e&&this._onInteraction}get supportsPrefix(){return this.#i&&this._onMessage}constructor(t){this.data=t;let r=t.toJSON(),{name:i}=r;if(this.#i=r.prefix_support??!1,this.#e=r.slash_support??!1,!this.#i&&!this.#e)throw new Error(`Command ${i} must support either slash or prefix commands.`)}attach(t){if(this.#s)return this;let r=this.data.toJSON(),{name:i,aliases:n}=r;if(this.#t=t,this.#r=t.logger,t.commands.has(i))throw new Error(`Command name "${i}" is already registered.`);let o=t.aliases.findKey(h=>h.has(i));if(o)throw new Error(`Command name "${i}" is already registered as an alias for command "${o}".`);for(let h of n){if(t.commands.has(h))throw new Error(`Alias "${h}" is already registered as a command name.`);let c=t.aliases.findKey(g=>g.has(h));if(c)throw new Error(`Alias "${h}" is already registered as an alias for command "${c}".`)}return t.commands.set(i,this),n.length>0&&t.aliases.set(i,new Set(n)),this.logger.debug(`Loaded Command ${i}`),this.#s=!0,this}onMessage(t){return this._onMessage=t,this}onInteraction(t){return this._onInteraction=t,this}},Q=class extends b{constructor(t){super(t.data);let r=t.data.toJSON(),i=t.execute;(r.prefix_support??!1)&&(t.onMessage||i)&&this.onMessage(n=>t.onMessage?t.onMessage(n):i?.(n)),(r.slash_support??!1)&&(t.onInteraction||i)&&this.onInteraction(n=>t.onInteraction?t.onInteraction(n):i?.(n))}}});import{ChatInputCommandInteraction as Bt,Locale as It,Message as Ot}from"discord.js";var f,L=l(()=>{"use strict";f=class{args;data;locale;constructor(t,r){this.client=t,this.args=r.args??[],"interaction"in r?this.data=r.interaction:this.data=r.message,this.locale=this.client.options.getDefaultLang?.(this)}isInteraction(){return this.data instanceof Bt}isMessage(){return this.data instanceof Ot}get author(){return this.isInteraction()?this.data.user:this.isMessage()?this.data.author:null}t(t,r){if(!this.client.i18n)throw new Error("i18n is not initialized");let i=this.locale??this.client.options.getDefaultLang?.(this)??(Array.isArray(this.client.i18n.options.fallbackLng)?this.client.i18n.options.fallbackLng[0]:this.client.i18n.options.fallbackLng)??It.EnglishUS,o=this.client.i18n.getFixedT(i)(t,r);return o===t&&r?.defaultValue?r.defaultValue:o}toJSON(){let{data:t,args:r,author:i}=this;return this.isInteraction()?{kind:"interaction",interaction:t,author:i,t:(n,o)=>this.t(n,o)}:{kind:"message",message:t,args:r,author:i,t:(n,o)=>this.t(n,o)}}}});var u,tt=l(()=>{"use strict";u=class{#t=null;#r=null;#e;#i=!1;get client(){if(!this.#t)throw new Error("Event is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Event is not attached to a client");return this.#r}#s=async(...t)=>{if(this.#t&&this.#e)try{await this.#e(this,...t)}catch(r){this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`,r)}};constructor(t,r=!1,i){this.name=t,this.once=r,i&&(this.#e=i)}#n(){this.#i||!this.#e||!this.#t||!this.#r||(this.once?this.client.once(this.name,this.#s):this.client.on(this.name,this.#s),this.#i=!0,this.logger.debug(`Loaded Event ${String(this.name)}`))}attach(t){return this.#t?this:(this.#t=t,this.#r=t.logger,this.#n(),this)}onExecute(t){return this.#e=t,this.#n(),this}}});function A(e){return Array.isArray(e[0])?[...e[0]]:e}var et=l(()=>{"use strict"});import{SlashCommandBuilder as Nt}from"discord.js";var rt,it=l(()=>{"use strict";et();rt=class extends Nt{prefix_support=!0;slash_support=!0;aliases=[];setAliases(...t){return this.aliases=A(t),this}addAliases(...t){return this.aliases=A([...this.aliases,...A(t)]),this}setPrefixSupport(t){return this.prefix_support=t,this}setSlashSupport(t){return this.slash_support=t,this}toJSON(){return super.toJSON()}toClientJSON(t){return{...this.toJSON()}}}});var st=l(()=>{"use strict";Z();L();tt();it()});var d=l(()=>{"use strict";X();st()});d();x();S();var $e="v0.1.2-beta.2";export{rt as ApplicationCommandBuilder,K as Client,Q as Command,b as CommandBuilder,f as Context,u as EventBuilder,C as I18nLoggerAdapter,s as LogLevel,E as Logger,w as LoggerLevel,M as LoggerStyle,Vt as LoggerStyleBackground,Tt as LoggerStyleEffect,zt as LoggerStyleText,R as LoggerTimestamp,at as allowedLocales,N as deleteMessageAfterSent,v as getDefaultLang,U as getFiles,j as getProjectRoot,O as toAllowedLocale,$e as version};