@stonyx/discord 0.1.1-beta.136 → 0.1.1-beta.138

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 +22 -9
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -11,7 +11,7 @@ Discord bot module for the [Stonyx framework](https://github.com/abofs/stonyx),
11
11
  * **Command auto-discovery:** Drop command files into a directory and the framework registers them automatically.
12
12
  * **Event handler auto-discovery:** Same pattern for Discord gateway events.
13
13
  * **Intent auto-derivation:** Required intents computed from discovered event handlers.
14
- * **Lazy initialization:** Bot only starts if a token is configured and commands/events exist.
14
+ * **Token-gated start:** The bot logs in only when a token is configured. With a token and no commands or events, it still logs in, so a send-only bot works.
15
15
  * **Singleton pattern:** Matches conventions of `@stonyx/sockets` and `@stonyx/events`.
16
16
  * **Utility methods:** sendMessage, reply with auto-chunking, role management, and more.
17
17
 
@@ -23,6 +23,8 @@ pnpm install @stonyx/discord
23
23
 
24
24
  ## Quick Start
25
25
 
26
+ The examples below are complete files: each one imports only from `@stonyx/discord` subpaths, so it runs in an app that depends on nothing but `@stonyx/discord`. The repo's `test/sample/` directory holds a command and an event handler written the same way ([source](https://github.com/abofs/stonyx-discord/tree/dev/test/sample)), and the test suite loads them on every run.
27
+
26
28
  ### 1. Create handler directories
27
29
 
28
30
  ```
@@ -36,8 +38,8 @@ discord-events/ # default directory (configurable)
36
38
 
37
39
  ```javascript
38
40
  // discord-commands/ping.js
39
- import { SlashCommandBuilder } from 'discord.js';
40
- import { Command } from '@stonyx/discord';
41
+ import { SlashCommandBuilder } from '@stonyx/discord/base';
42
+ import Command from '@stonyx/discord/command';
41
43
 
42
44
  export default class PingCommand extends Command {
43
45
  data = new SlashCommandBuilder()
@@ -54,14 +56,14 @@ export default class PingCommand extends Command {
54
56
 
55
57
  ```javascript
56
58
  // discord-events/message-create.js
57
- import { EventHandler } from '@stonyx/discord';
59
+ import EventHandler from '@stonyx/discord/event-handler';
58
60
 
59
61
  export default class MessageCreateHandler extends EventHandler {
60
62
  static event = 'messageCreate';
61
63
 
62
- handle(message) {
64
+ async handle(message) {
63
65
  if (message.author.bot) return;
64
- console.log(`${message.author.username}: ${message.content}`);
66
+ if (message.content === '!ping') await message.reply('pong');
65
67
  }
66
68
  }
67
69
  ```
@@ -74,7 +76,18 @@ Stonyx auto-initializes the bot when your app boots — no manual wiring needed:
74
76
  stonyx serve
75
77
  ```
76
78
 
77
- `Discord.init()` (called by the Stonyx module loader) awaits `new DiscordBot().init()`, which discovers commands/events, derives intents, and connects to the gateway. The lazy-init guards still apply: if `DISCORD_TOKEN` is unset or no commands/events exist, the bot skips login.
79
+ `Discord.init()` (called by the Stonyx module loader) awaits `new DiscordBot().init()`, which discovers commands/events, derives intents, and connects to the gateway. If `DISCORD_TOKEN` is unset, the bot skips login. With a token it always logs in, even when no commands or events exist.
80
+
81
+ ## Exports
82
+
83
+ | Import | Provides |
84
+ |--------|----------|
85
+ | `@stonyx/discord` | `Discord` (default) — the Stonyx module entry point; no named exports |
86
+ | `@stonyx/discord/bot` | `DiscordBot` (default) — the bot singleton and its utility methods |
87
+ | `@stonyx/discord/command` | `Command` (default) — base class for slash commands |
88
+ | `@stonyx/discord/event-handler` | `EventHandler` (default) — base class for gateway event handlers |
89
+ | `@stonyx/discord/message` | `chunkMessage` — message chunking helper |
90
+ | `@stonyx/discord/base` | Re-exports of common discord.js classes (`SlashCommandBuilder`, `Client`, `GatewayIntentBits`, `Partials`, ...) |
78
91
 
79
92
  ## Command Architecture
80
93
 
@@ -148,7 +161,7 @@ The framework automatically computes the required intents from your registered e
148
161
  | `voiceStateUpdate` | `GuildVoiceStates` |
149
162
  | `interactionCreate` | *(none — handled by default)* |
150
163
 
151
- **`Guilds` is always included** when commands are registered.
164
+ **`Guilds` is always included**, whether or not any commands or events are registered.
152
165
 
153
166
  ### Intent-to-Partial Mapping
154
167
 
@@ -174,7 +187,7 @@ Values are resolved against `GatewayIntentBits` and `Partials` enums from discor
174
187
 
175
188
  ## Utility Methods
176
189
 
177
- All methods are on the `DiscordBot` instance (accessible via `this._bot` in commands/handlers or `new DiscordBot()`).
190
+ All methods are on the `DiscordBot` instance (accessible via `this._bot` in commands/handlers, or `new DiscordBot()` after `import DiscordBot from '@stonyx/discord/bot'`).
178
191
 
179
192
  ### sendMessage(content, channelId, imagePath?)
180
193
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.1.1-beta.136",
7
+ "version": "0.1.1-beta.138",
8
8
  "description": "Discord bot module for the Stonyx framework",
9
9
  "main": "dist/main.js",
10
10
  "types": "dist/main.d.ts",
@@ -64,13 +64,13 @@
64
64
  "stonyx": ">=0.2.3-beta.4"
65
65
  },
66
66
  "devDependencies": {
67
- "@stonyx/utils": "0.2.3-beta.27",
67
+ "@stonyx/utils": "0.2.3-beta.28",
68
68
  "@types/node": "^25.5.2",
69
69
  "@types/qunit": "^2.19.13",
70
70
  "@types/sinon": "^21.0.1",
71
71
  "qunit": "^2.24.1",
72
72
  "sinon": "^21.0.0",
73
- "stonyx": "0.2.3-beta.100",
73
+ "stonyx": "0.2.3-beta.101",
74
74
  "tsx": "^4.21.0",
75
75
  "typescript": "^5.8.3"
76
76
  },