@scotthamilton77/discord-bot-lib 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +9 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -38,7 +38,8 @@ const bot = await Bot.fromConfig({
38
38
  });
39
39
 
40
40
  // Every incoming message — route by metadata
41
- bot.onMessage(async (event) => {
41
+ // onMessage returns an unsubscribe function
42
+ const unsubscribe = bot.onMessage(async (event) => {
42
43
  if (event.isMention) {
43
44
  await bot.send(event.channelId, `Hello, ${event.author.username}!`);
44
45
  }
@@ -47,8 +48,11 @@ bot.onMessage(async (event) => {
47
48
  }
48
49
  });
49
50
 
50
- // Error handling
51
+ // Error handling — also returns unsubscribe
51
52
  bot.on("error", (err) => console.error("Bot error:", err.message));
53
+
54
+ // Clean disconnect clears all handlers
55
+ await bot.disconnect();
52
56
  ```
53
57
 
54
58
  ## Async Iterables
@@ -108,6 +112,9 @@ manager.on("botError", (bot, error) => {
108
112
  console.log(manager.status());
109
113
  // [{ id: "a", name: "Alpha", status: "ready" }, ...]
110
114
 
115
+ // Remove a bot — detaches all handlers from that bot
116
+ manager.removeBot("a");
117
+
111
118
  // Clean shutdown
112
119
  await manager.shutdown();
113
120
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scotthamilton77/discord-bot-lib",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "TypeScript library for managing Discord bot identities, messaging, and multi-bot coordination",
5
5
  "type": "module",
6
6
  "sideEffects": false,