wumbly 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wumbly contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,227 @@
1
- # Temporary Holding Version
1
+ # wumbly
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A client and framework for Fluxer bots. It adds prefix commands, events, middleware, cooldowns and directory loading on top of the Fluxer client.
4
+
5
+ The source is TypeScript. The build emits ESM, CJS and declaration files. Bun runs the TS directly; Node uses the build.
6
+
7
+ Current state: message/prefix commands, events and provider-based voice. Slash/application commands are not included yet.
8
+
9
+ ## Structure
10
+
11
+ ```
12
+ src/
13
+ client.ts Client
14
+ commands/ definitions, context, store, cooldown
15
+ events/ Event, EventStore
16
+ loaders/ directory scanning + dynamic import
17
+ runtime/environment.ts Bun/Node detection
18
+ util/tokenize.ts argument parser with quotes
19
+ voice/ provider interface, no native dependencies
20
+ test/ tests with node:test
21
+ examples/
22
+ ts/ TypeScript example
23
+ js/ JavaScript example
24
+ ```
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ npm install wumbly
30
+ ```
31
+
32
+ To work on this repository:
33
+
34
+ ```bash
35
+ npm install
36
+ npm run typecheck
37
+ npm run build
38
+ ```
39
+
40
+ Bun:
41
+
42
+ ```bash
43
+ FLUXER_BOT_TOKEN=... bun run examples/ts/basic.ts
44
+ ```
45
+
46
+ Node:
47
+
48
+ ```bash
49
+ npm run build
50
+ FLUXER_BOT_TOKEN=... node examples/js/basic.js
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ```ts
56
+ import { Client } from 'wumbly';
57
+
58
+ const client = new Client({
59
+ prefix: ['!', 'w!'],
60
+ owners: ['YOUR_ID'],
61
+ commandsDir: './commands',
62
+ eventsDir: './events',
63
+ });
64
+
65
+ client.on('error', (error) => {
66
+ client.logger.error('Client error', { error: String(error) });
67
+ });
68
+
69
+ await client.start();
70
+ ```
71
+
72
+ A command:
73
+
74
+ ```ts
75
+ import { createCommand } from 'wumbly';
76
+
77
+ export default createCommand({
78
+ name: 'ping',
79
+ description: 'Replies with Pong.',
80
+ run: async (ctx) => {
81
+ await ctx.reply('Pong!');
82
+ },
83
+ });
84
+ ```
85
+
86
+ An event:
87
+
88
+ ```ts
89
+ import { createEvent } from 'wumbly';
90
+
91
+ export default createEvent({
92
+ event: 'ready',
93
+ once: true,
94
+ run: (client) => {
95
+ client.logger.info(`Online as ${client.user?.username}`);
96
+ },
97
+ });
98
+ ```
99
+
100
+ The loader accepts default exports, named exports and arrays. A single file can export more than one command or event.
101
+
102
+ ## Command context
103
+
104
+ `ctx` contains:
105
+
106
+ - `client`, `message`, `command`, `author`
107
+ - `args` (tokens) and `rest` (tokens joined by a space)
108
+ - `input` (text after the prefix, including the command name)
109
+ - `channel`, `guild`, `member`
110
+ - `reply(options)` and `send(options)`
111
+
112
+ The parser respects single quotes, double quotes and backslashes:
113
+
114
+ ```
115
+ !echo "text with spaces" -> args: ['text with spaces']
116
+ ```
117
+
118
+ ## Middleware and cooldowns
119
+
120
+ Middleware runs before the command. Call `next()` to continue; skip it to stop. Code after `await next()` runs after the command, so a middleware can also measure or clean up around it.
121
+
122
+ ```ts
123
+ import { createCommand, createMiddleware } from 'wumbly';
124
+
125
+ export default createCommand({
126
+ name: 'ban',
127
+ cooldown: { limit: 2, window: 60_000, scope: 'user' },
128
+ middlewares: [
129
+ createMiddleware({
130
+ name: 'guild-only',
131
+ run: async (ctx, next) => {
132
+ if (!ctx.member) {
133
+ await ctx.reply('This command only works in a server.');
134
+ return;
135
+ }
136
+ await next();
137
+ },
138
+ }),
139
+ ],
140
+ run: async (ctx) => {
141
+ await ctx.reply('ok');
142
+ },
143
+ });
144
+ ```
145
+
146
+ Global middleware goes in the `middlewares` client option. Global middleware runs first, then the command's own, then the command.
147
+
148
+ Cooldown scopes: `user`, `guild`, `channel`, `global`.
149
+
150
+ ## Client options
151
+
152
+ | Option | Default | Purpose |
153
+ | --- | --- | --- |
154
+ | `client` | `{}` | Options forwarded to the underlying client |
155
+ | `prefix` | `'!'` | String, list or function that resolves the prefix |
156
+ | `owners` | `[]` | IDs allowed to use `ownerOnly` commands |
157
+ | `allowBots` | `false` | Allow commands from other bots |
158
+ | `allowDMs` | `true` | Allow commands in DMs |
159
+ | `middlewares` | `[]` | Global middleware, in order |
160
+ | `commandsDir` | — | Command directory |
161
+ | `eventsDir` | — | Event directory |
162
+ | `loadDirs` | `[]` | Extra directories scanned for both |
163
+ | `extensions` | JS on Node, JS+TS on Bun | Loader extensions |
164
+ | `ignore` | `[]` | File/directory names skipped by the loader |
165
+ | `cacheBust` | `true` | Add a unique query string to imports |
166
+ | `voice` | — | Voice provider |
167
+ | `messages` | English | Error, cooldown and DM strings |
168
+ | `onCommandError` | log + reply | Command error handler |
169
+ | `onEventError` | log | Event error handler |
170
+
171
+ You can also register manually:
172
+
173
+ ```ts
174
+ client.registerCommand(command);
175
+ client.registerEvent(event);
176
+ client.register(command, event);
177
+ ```
178
+
179
+ `client.commands.list()`, `client.commands.get('name')`, `client.reload()` and `client.stop()` are available on the client.
180
+
181
+ ## Voice
182
+
183
+ Voice is optional and never bundled. Native voice stacks ship platform-specific binaries, which are a problem on Termux/Android, especially on 32-bit builds. Wumbly has no native dependencies.
184
+
185
+ Voice sits behind an interface:
186
+
187
+ ```ts
188
+ import type { VoiceProvider, VoiceSession } from 'wumbly';
189
+
190
+ const provider: VoiceProvider = {
191
+ name: 'my-provider',
192
+ async join(client, channel): Promise<VoiceSession> {
193
+ // open the transport, store the session_id, etc.
194
+ return {
195
+ provider: 'my-provider',
196
+ channel,
197
+ async leave() {
198
+ // close the transport
199
+ },
200
+ };
201
+ },
202
+ };
203
+
204
+ const client = new Client({ voice: provider });
205
+ ```
206
+
207
+ Without a provider, `client.voice.join(channel)` throws `VoiceUnavailableError`.
208
+
209
+ A provider can use a UDP path or a pure-JS WebRTC transport. The interface accepts either.
210
+
211
+ ## Runtime
212
+
213
+ - Node 22.13 or newer.
214
+ - Bun runs `.ts` files without a build.
215
+ - On Node, use the build (`dist/`) or a TS loader.
216
+
217
+ ## Scripts
218
+
219
+ ```bash
220
+ npm run build # ESM + CJS + .d.ts
221
+ npm run typecheck # tsc --noEmit
222
+ npm test # build + node:test
223
+ npm run dev # Bun example
224
+ npm run dev:node # build + Node example
225
+ ```
226
+
227
+ MIT license. Not affiliated with Fluxer or any other bot framework.