@stonyx/discord 0.1.1-alpha.21 → 0.1.1-alpha.22
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 +8 -8
- package/package.json +1 -1
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
|
-
* **
|
|
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,7 +23,7 @@ pnpm install @stonyx/discord
|
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
|
-
|
|
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
27
|
|
|
28
28
|
### 1. Create handler directories
|
|
29
29
|
|
|
@@ -38,7 +38,7 @@ discord-events/ # default directory (configurable)
|
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
40
|
// discord-commands/ping.js
|
|
41
|
-
import { SlashCommandBuilder } from 'discord
|
|
41
|
+
import { SlashCommandBuilder } from '@stonyx/discord/base';
|
|
42
42
|
import Command from '@stonyx/discord/command';
|
|
43
43
|
|
|
44
44
|
export default class PingCommand extends Command {
|
|
@@ -61,9 +61,9 @@ import EventHandler from '@stonyx/discord/event-handler';
|
|
|
61
61
|
export default class MessageCreateHandler extends EventHandler {
|
|
62
62
|
static event = 'messageCreate';
|
|
63
63
|
|
|
64
|
-
handle(message) {
|
|
64
|
+
async handle(message) {
|
|
65
65
|
if (message.author.bot) return;
|
|
66
|
-
|
|
66
|
+
if (message.content === '!ping') await message.reply('pong');
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
```
|
|
@@ -76,9 +76,9 @@ Stonyx auto-initializes the bot when your app boots — no manual wiring needed:
|
|
|
76
76
|
stonyx serve
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
`Discord.init()` (called by the Stonyx module loader) awaits `new DiscordBot().init()`, which discovers commands/events, derives intents, and connects to the gateway.
|
|
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
80
|
|
|
81
|
-
##
|
|
81
|
+
## Exports
|
|
82
82
|
|
|
83
83
|
| Import | Provides |
|
|
84
84
|
|--------|----------|
|
|
@@ -161,7 +161,7 @@ The framework automatically computes the required intents from your registered e
|
|
|
161
161
|
| `voiceStateUpdate` | `GuildVoiceStates` |
|
|
162
162
|
| `interactionCreate` | *(none — handled by default)* |
|
|
163
163
|
|
|
164
|
-
**`Guilds` is always included
|
|
164
|
+
**`Guilds` is always included**, whether or not any commands or events are registered.
|
|
165
165
|
|
|
166
166
|
### Intent-to-Partial Mapping
|
|
167
167
|
|