stoatx 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { Client as Client$1, Message } from 'stoat.js';
1
+ import { Client as Client$1, Message } from '@stoatx/client';
2
+ export * from '@stoatx/client';
2
3
 
3
4
  /**
4
5
  * Permission types for commands
@@ -469,7 +470,7 @@ declare class StoatxHandler {
469
470
  * });
470
471
  * ```
471
472
  */
472
- handle(message: any): Promise<boolean>;
473
+ handle(message: Message): Promise<boolean>;
473
474
  /**
474
475
  * Handle a raw message string with metadata
475
476
  *
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Client as Client$1, Message } from 'stoat.js';
1
+ import { Client as Client$1, Message } from '@stoatx/client';
2
+ export * from '@stoatx/client';
2
3
 
3
4
  /**
4
5
  * Permission types for commands
@@ -469,7 +470,7 @@ declare class StoatxHandler {
469
470
  * });
470
471
  * ```
471
472
  */
472
- handle(message: any): Promise<boolean>;
473
+ handle(message: Message): Promise<boolean>;
473
474
  /**
474
475
  * Handle a raw message string with metadata
475
476
  *
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -59,13 +60,14 @@ var METADATA_KEYS = {
59
60
 
60
61
  // src/decorators/store.ts
61
62
  var DecoratorStore = class _DecoratorStore {
63
+ static instance;
64
+ /** Stoat classes with their SimpleCommand methods */
65
+ stoatClasses = /* @__PURE__ */ new Map();
66
+ /** Registered commands from @Stoat/@SimpleCommand decorators */
67
+ commands = [];
68
+ /** Whether the store has been initialized */
69
+ initialized = false;
62
70
  constructor() {
63
- /** Stoat classes with their SimpleCommand methods */
64
- this.stoatClasses = /* @__PURE__ */ new Map();
65
- /** Registered commands from @Stoat/@SimpleCommand decorators */
66
- this.commands = [];
67
- /** Whether the store has been initialized */
68
- this.initialized = false;
69
71
  }
70
72
  static getInstance() {
71
73
  if (!_DecoratorStore.instance) {
@@ -209,12 +211,20 @@ var path = __toESM(require("path"));
209
211
  var fs = __toESM(require("fs/promises"));
210
212
  var import_node_url = require("url");
211
213
  var import_tinyglobby = require("tinyglobby");
212
- var _CommandRegistry = class _CommandRegistry {
214
+ var CommandRegistry = class _CommandRegistry {
215
+ static DEFAULT_AUTO_DISCOVERY_IGNORES = [
216
+ "**/node_modules/**",
217
+ "**/.git/**",
218
+ "**/*.d.ts",
219
+ "**/*.test.*",
220
+ "**/*.spec.*"
221
+ ];
222
+ commands = /* @__PURE__ */ new Map();
223
+ aliases = /* @__PURE__ */ new Map();
224
+ registeredEvents = [];
225
+ extensions;
226
+ processedStoatClasses = /* @__PURE__ */ new Set();
213
227
  constructor(extensions = [".js", ".mjs", ".cjs"]) {
214
- this.commands = /* @__PURE__ */ new Map();
215
- this.aliases = /* @__PURE__ */ new Map();
216
- this.registeredEvents = [];
217
- this.processedStoatClasses = /* @__PURE__ */ new Set();
218
228
  this.extensions = extensions;
219
229
  }
220
230
  /**
@@ -273,7 +283,7 @@ var _CommandRegistry = class _CommandRegistry {
273
283
  async isLikelyCommandModule(filePath) {
274
284
  try {
275
285
  const source = await fs.readFile(filePath, "utf8");
276
- return source.includes("Stoat") || source.includes("SimpleCommand") || source.includes("Command") || source.includes("stoatx:command");
286
+ return source.includes("Stoat") || source.includes("SimpleCommand") || source.includes("stoatx:command");
277
287
  } catch {
278
288
  return true;
279
289
  }
@@ -462,19 +472,12 @@ var _CommandRegistry = class _CommandRegistry {
462
472
  return void 0;
463
473
  }
464
474
  };
465
- _CommandRegistry.DEFAULT_AUTO_DISCOVERY_IGNORES = [
466
- "**/node_modules/**",
467
- "**/.git/**",
468
- "**/*.d.ts",
469
- "**/*.test.*",
470
- "**/*.spec.*"
471
- ];
472
- var CommandRegistry = _CommandRegistry;
473
475
 
474
476
  // src/handler.ts
475
477
  var import_reflect_metadata5 = require("reflect-metadata");
476
- var import_stoat = require("stoat.js");
477
- var Client = class extends import_stoat.Client {
478
+ var import_client = require("@stoatx/client");
479
+ var Client = class extends import_client.Client {
480
+ handler;
478
481
  constructor(options) {
479
482
  super();
480
483
  this.handler = new StoatxHandler({ ...options, client: this });
@@ -490,8 +493,15 @@ var Client = class extends import_stoat.Client {
490
493
  }
491
494
  };
492
495
  var StoatxHandler = class {
496
+ commandsDir;
497
+ discoveryOptions;
498
+ prefixResolver;
499
+ owners;
500
+ registry;
501
+ cooldowns = /* @__PURE__ */ new Map();
502
+ disableMentionPrefix;
503
+ client;
493
504
  constructor(options) {
494
- this.cooldowns = /* @__PURE__ */ new Map();
495
505
  this.client = options.client;
496
506
  this.commandsDir = options.commandsDir;
497
507
  this.discoveryOptions = options.discovery;
@@ -527,10 +537,11 @@ var StoatxHandler = class {
527
537
  );
528
538
  }
529
539
  };
540
+ const eventName = eventDef.event;
530
541
  if (eventDef.type === "once") {
531
- this.client.once(eventDef.event, handler);
542
+ this.client.once(eventName, handler);
532
543
  } else {
533
- this.client.on(eventDef.event, handler);
544
+ this.client.on(eventName, handler);
534
545
  }
535
546
  }
536
547
  }
@@ -599,7 +610,7 @@ var StoatxHandler = class {
599
610
  const channelId = message.channel.id;
600
611
  const serverId = message.server?.id;
601
612
  const reply = async (content) => {
602
- return await message.channel.sendMessage(content);
613
+ return await message.channel.send(content);
603
614
  };
604
615
  return this.handleMessage(rawContent, message, {
605
616
  authorId,
@@ -679,7 +690,6 @@ var StoatxHandler = class {
679
690
  await instance.onError(ctx, error);
680
691
  } else {
681
692
  console.error(`[Stoatx] Error in command ${metadata.name}:`, error);
682
- await ctx.reply(`An error occurred: ${error.message}`);
683
693
  }
684
694
  return false;
685
695
  }
@@ -773,6 +783,9 @@ var StoatxHandler = class {
773
783
  commandCooldowns.set(userId, Date.now() + metadata.cooldown);
774
784
  }
775
785
  };
786
+
787
+ // src/index.ts
788
+ __reExport(index_exports, require("@stoatx/client"), module.exports);
776
789
  // Annotate the CommonJS export names for ESM import in node:
777
790
  0 && (module.exports = {
778
791
  Client,
@@ -787,5 +800,6 @@ var StoatxHandler = class {
787
800
  getEventsMetadata,
788
801
  getGuards,
789
802
  getSimpleCommands,
790
- isStoatClass
803
+ isStoatClass,
804
+ ...require("@stoatx/client")
791
805
  });
package/dist/index.mjs CHANGED
@@ -11,13 +11,14 @@ var METADATA_KEYS = {
11
11
 
12
12
  // src/decorators/store.ts
13
13
  var DecoratorStore = class _DecoratorStore {
14
+ static instance;
15
+ /** Stoat classes with their SimpleCommand methods */
16
+ stoatClasses = /* @__PURE__ */ new Map();
17
+ /** Registered commands from @Stoat/@SimpleCommand decorators */
18
+ commands = [];
19
+ /** Whether the store has been initialized */
20
+ initialized = false;
14
21
  constructor() {
15
- /** Stoat classes with their SimpleCommand methods */
16
- this.stoatClasses = /* @__PURE__ */ new Map();
17
- /** Registered commands from @Stoat/@SimpleCommand decorators */
18
- this.commands = [];
19
- /** Whether the store has been initialized */
20
- this.initialized = false;
21
22
  }
22
23
  static getInstance() {
23
24
  if (!_DecoratorStore.instance) {
@@ -161,12 +162,20 @@ import * as path from "path";
161
162
  import * as fs from "fs/promises";
162
163
  import { pathToFileURL } from "url";
163
164
  import { glob } from "tinyglobby";
164
- var _CommandRegistry = class _CommandRegistry {
165
+ var CommandRegistry = class _CommandRegistry {
166
+ static DEFAULT_AUTO_DISCOVERY_IGNORES = [
167
+ "**/node_modules/**",
168
+ "**/.git/**",
169
+ "**/*.d.ts",
170
+ "**/*.test.*",
171
+ "**/*.spec.*"
172
+ ];
173
+ commands = /* @__PURE__ */ new Map();
174
+ aliases = /* @__PURE__ */ new Map();
175
+ registeredEvents = [];
176
+ extensions;
177
+ processedStoatClasses = /* @__PURE__ */ new Set();
165
178
  constructor(extensions = [".js", ".mjs", ".cjs"]) {
166
- this.commands = /* @__PURE__ */ new Map();
167
- this.aliases = /* @__PURE__ */ new Map();
168
- this.registeredEvents = [];
169
- this.processedStoatClasses = /* @__PURE__ */ new Set();
170
179
  this.extensions = extensions;
171
180
  }
172
181
  /**
@@ -225,7 +234,7 @@ var _CommandRegistry = class _CommandRegistry {
225
234
  async isLikelyCommandModule(filePath) {
226
235
  try {
227
236
  const source = await fs.readFile(filePath, "utf8");
228
- return source.includes("Stoat") || source.includes("SimpleCommand") || source.includes("Command") || source.includes("stoatx:command");
237
+ return source.includes("Stoat") || source.includes("SimpleCommand") || source.includes("stoatx:command");
229
238
  } catch {
230
239
  return true;
231
240
  }
@@ -414,19 +423,12 @@ var _CommandRegistry = class _CommandRegistry {
414
423
  return void 0;
415
424
  }
416
425
  };
417
- _CommandRegistry.DEFAULT_AUTO_DISCOVERY_IGNORES = [
418
- "**/node_modules/**",
419
- "**/.git/**",
420
- "**/*.d.ts",
421
- "**/*.test.*",
422
- "**/*.spec.*"
423
- ];
424
- var CommandRegistry = _CommandRegistry;
425
426
 
426
427
  // src/handler.ts
427
428
  import "reflect-metadata";
428
- import { Client as StoatClient } from "stoat.js";
429
+ import { Client as StoatClient } from "@stoatx/client";
429
430
  var Client = class extends StoatClient {
431
+ handler;
430
432
  constructor(options) {
431
433
  super();
432
434
  this.handler = new StoatxHandler({ ...options, client: this });
@@ -442,8 +444,15 @@ var Client = class extends StoatClient {
442
444
  }
443
445
  };
444
446
  var StoatxHandler = class {
447
+ commandsDir;
448
+ discoveryOptions;
449
+ prefixResolver;
450
+ owners;
451
+ registry;
452
+ cooldowns = /* @__PURE__ */ new Map();
453
+ disableMentionPrefix;
454
+ client;
445
455
  constructor(options) {
446
- this.cooldowns = /* @__PURE__ */ new Map();
447
456
  this.client = options.client;
448
457
  this.commandsDir = options.commandsDir;
449
458
  this.discoveryOptions = options.discovery;
@@ -479,10 +488,11 @@ var StoatxHandler = class {
479
488
  );
480
489
  }
481
490
  };
491
+ const eventName = eventDef.event;
482
492
  if (eventDef.type === "once") {
483
- this.client.once(eventDef.event, handler);
493
+ this.client.once(eventName, handler);
484
494
  } else {
485
- this.client.on(eventDef.event, handler);
495
+ this.client.on(eventName, handler);
486
496
  }
487
497
  }
488
498
  }
@@ -551,7 +561,7 @@ var StoatxHandler = class {
551
561
  const channelId = message.channel.id;
552
562
  const serverId = message.server?.id;
553
563
  const reply = async (content) => {
554
- return await message.channel.sendMessage(content);
564
+ return await message.channel.send(content);
555
565
  };
556
566
  return this.handleMessage(rawContent, message, {
557
567
  authorId,
@@ -631,7 +641,6 @@ var StoatxHandler = class {
631
641
  await instance.onError(ctx, error);
632
642
  } else {
633
643
  console.error(`[Stoatx] Error in command ${metadata.name}:`, error);
634
- await ctx.reply(`An error occurred: ${error.message}`);
635
644
  }
636
645
  return false;
637
646
  }
@@ -725,6 +734,9 @@ var StoatxHandler = class {
725
734
  commandCooldowns.set(userId, Date.now() + metadata.cooldown);
726
735
  }
727
736
  };
737
+
738
+ // src/index.ts
739
+ export * from "@stoatx/client";
728
740
  export {
729
741
  Client,
730
742
  CommandRegistry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stoatx",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "A high-performance, decorator-based command handler for the Stoat ecosystem.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "reflect-metadata": "^0.2.2",
32
- "stoat.js": "^7.3.6",
33
- "tinyglobby": "^0.2.10"
32
+ "tinyglobby": "^0.2.10",
33
+ "@stoatx/client": "0.1.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^20.0.0",