stonyx 0.2.3-alpha.2 → 0.2.3-alpha.4
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/.claude/index.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Stonyx CLI Guide
|
|
2
2
|
|
|
3
|
+
See [docs/index.md](../docs/index.md) for full documentation including conventions, modules, lifecycle, and API reference.
|
|
4
|
+
|
|
3
5
|
## Installation
|
|
4
6
|
|
|
5
7
|
Stonyx is the core framework package. The CLI is provided by the `stonyx` binary defined in `package.json`.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Discord Conventions
|
|
2
|
+
|
|
3
|
+
Conventions for projects using `@stonyx/discord`.
|
|
4
|
+
|
|
5
|
+
## Command Files
|
|
6
|
+
|
|
7
|
+
- One class per file in the configured command directory (default: `discord-commands/`)
|
|
8
|
+
- Each file default-exports a class extending `Command` from `@stonyx/discord`
|
|
9
|
+
- Class must define a `data` property (a `SlashCommandBuilder` instance) and an `async execute(interaction)` method
|
|
10
|
+
- Class ordering: static properties → `data` → `execute()`
|
|
11
|
+
- Filenames use kebab-case; `forEachFileImport` converts to camelCase for internal registration
|
|
12
|
+
- Permission checks belong in the consuming application, not in the module
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { Command } from '@stonyx/discord';
|
|
16
|
+
import { SlashCommandBuilder } from 'discord.js';
|
|
17
|
+
|
|
18
|
+
export default class PingCommand extends Command {
|
|
19
|
+
data = new SlashCommandBuilder()
|
|
20
|
+
.setName('ping')
|
|
21
|
+
.setDescription('Replies with Pong!');
|
|
22
|
+
|
|
23
|
+
async execute(interaction) {
|
|
24
|
+
await interaction.reply('Pong!');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Event Handler Files
|
|
30
|
+
|
|
31
|
+
- One class per file in the configured event directory (default: `discord-events/`)
|
|
32
|
+
- Each file default-exports a class extending `EventHandler` from `@stonyx/discord`
|
|
33
|
+
- Class must set `static event` to a valid Discord.js event name (e.g., `'messageCreate'`, `'voiceStateUpdate'`)
|
|
34
|
+
- Class must implement a `handle(...args)` method matching the Discord.js event signature
|
|
35
|
+
- Class ordering: static properties → `handle()`
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { EventHandler } from '@stonyx/discord';
|
|
39
|
+
|
|
40
|
+
export default class WelcomeHandler extends EventHandler {
|
|
41
|
+
static event = 'guildMemberAdd';
|
|
42
|
+
|
|
43
|
+
handle(member) {
|
|
44
|
+
// Welcome new member
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
- Config namespace: `config.discord`
|
|
52
|
+
- Environment variables prefixed with `DISCORD_`
|
|
53
|
+
- Logging: `log.discord()` — configured via `logColor: '#7289da'` and `logMethod: 'discord'`
|
|
54
|
+
- Intent auto-derivation: the module computes required gateway intents from discovered event handlers; use `additionalIntents` in config for edge cases
|
|
55
|
+
|
|
56
|
+
## Module Keywords
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"keywords": ["stonyx-async", "stonyx-module"]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`stonyx-async` indicates the module's `init()` is async and must be awaited by the framework.
|
|
@@ -103,6 +103,12 @@ WebSocket handlers. Class ordering: static properties → `server()` method →
|
|
|
103
103
|
|
|
104
104
|
Exports: `SocketServer`, `SocketClient`, `Handler`, `Sockets`
|
|
105
105
|
|
|
106
|
+
## `@stonyx/discord`
|
|
107
|
+
|
|
108
|
+
Discord bot with command and event handler auto-discovery. Class ordering: static properties → `data` / `static event` → `execute()` / `handle()`.
|
|
109
|
+
|
|
110
|
+
Exports: `DiscordBot`, `Command`, `EventHandler`, `Discord`, `chunkMessage`
|
|
111
|
+
|
|
106
112
|
## `@stonyx/oauth`
|
|
107
113
|
|
|
108
114
|
OAuth providers. Class ordering: constructor with `super()` → async methods → transform methods.
|
|
@@ -20,4 +20,5 @@ Universal rules that apply to every Stonyx project. Section-specific conventions
|
|
|
20
20
|
- [Framework Modules](./framework-modules.md) — when to use which `@stonyx/*` module
|
|
21
21
|
- [ORM Conventions](./orm-conventions.md) — models, serializers, access control, transforms, hooks
|
|
22
22
|
- [REST Conventions](./rest-conventions.md) — REST server request classes and handlers
|
|
23
|
+
- [Discord Conventions](./discord-conventions.md) — Discord bot commands and event handlers
|
|
23
24
|
- [Testing Conventions](./testing-conventions.md) — test organization, patterns, and tooling
|
|
@@ -40,8 +40,7 @@ Flat file structure at root level — non-directory project files live at the pr
|
|
|
40
40
|
| `requests/` | REST request handlers | When using `@stonyx/rest-server` |
|
|
41
41
|
| `crons/` | Scheduled tasks | When using `@stonyx/cron` |
|
|
42
42
|
| `clients/` | External API clients | When fetching external data |
|
|
43
|
-
| `
|
|
44
|
-
| `test/` | Tests | Always |
|
|
43
|
+
| `test/`| Tests | Always |
|
|
45
44
|
| `utils.js` or `utils/` | Project-specific reusable logic | As needed (never duplicate `@stonyx/utils`) |
|
|
46
45
|
|
|
47
46
|
### Nested Model Directories
|
package/package.json
CHANGED
package/src/cli/new.js
CHANGED
|
@@ -33,6 +33,11 @@ const MODULE_OPTIONS = [
|
|
|
33
33
|
{
|
|
34
34
|
question: 'Will this project need pub/sub events?',
|
|
35
35
|
package: '@stonyx/events'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
question: 'Will this project need a Discord bot?',
|
|
39
|
+
package: '@stonyx/discord',
|
|
40
|
+
dirs: ['discord-commands', 'discord-events']
|
|
36
41
|
}
|
|
37
42
|
];
|
|
38
43
|
|