@stonyx/discord 0.1.1-alpha.20 → 0.1.1-alpha.21
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/README.md +16 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ pnpm install @stonyx/discord
|
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
|
+
[`test/sample/`](https://github.com/abofs/stonyx-discord/tree/dev/test/sample) is the canonical usage reference: a working command and event handler, imported the way an app imports them.
|
|
27
|
+
|
|
26
28
|
### 1. Create handler directories
|
|
27
29
|
|
|
28
30
|
```
|
|
@@ -37,7 +39,7 @@ discord-events/ # default directory (configurable)
|
|
|
37
39
|
```javascript
|
|
38
40
|
// discord-commands/ping.js
|
|
39
41
|
import { SlashCommandBuilder } from 'discord.js';
|
|
40
|
-
import
|
|
42
|
+
import Command from '@stonyx/discord/command';
|
|
41
43
|
|
|
42
44
|
export default class PingCommand extends Command {
|
|
43
45
|
data = new SlashCommandBuilder()
|
|
@@ -54,7 +56,7 @@ export default class PingCommand extends Command {
|
|
|
54
56
|
|
|
55
57
|
```javascript
|
|
56
58
|
// discord-events/message-create.js
|
|
57
|
-
import
|
|
59
|
+
import EventHandler from '@stonyx/discord/event-handler';
|
|
58
60
|
|
|
59
61
|
export default class MessageCreateHandler extends EventHandler {
|
|
60
62
|
static event = 'messageCreate';
|
|
@@ -76,6 +78,17 @@ stonyx serve
|
|
|
76
78
|
|
|
77
79
|
`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.
|
|
78
80
|
|
|
81
|
+
## Package 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`, ...) |
|
|
91
|
+
|
|
79
92
|
## Command Architecture
|
|
80
93
|
|
|
81
94
|
### How commands are discovered
|
|
@@ -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-alpha.
|
|
7
|
+
"version": "0.1.1-alpha.21",
|
|
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.
|
|
67
|
+
"@stonyx/utils": "0.2.3-beta.27",
|
|
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.
|
|
73
|
+
"stonyx": "0.2.3-beta.98",
|
|
74
74
|
"tsx": "^4.21.0",
|
|
75
75
|
"typescript": "^5.8.3"
|
|
76
76
|
},
|