You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/events.mdx
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,16 @@ These fire as your session connects, authenticates, and (occasionally) drops. Ev
63
63
|`auth-exhausted`|`{ sessionId, kind, attempts, max }`| The [`authGuard`](/configuration#authguard) budget ran out — too many QR / pairing regenerations. `kind` is `'qr' \| 'pairing'`. The client stops and will not auto-retry until you call `connect()` again. |
64
64
|`error`|`{ sessionId, error }`| An internal connection error surfaced as an `Error`. |
65
65
66
+
### Commands
67
+
68
+
Emitted by the [command framework](/commands). All three are silent no-ops unless you listen.
69
+
70
+
| Event | Payload | Fires when |
71
+
| ----- | ------- | ---------- |
72
+
|`command-blocked`|`{ command, reason, retryIn?, ctx }`| A guard stopped a command. `reason` is `'group-only' \| 'private-only' \| 'admin-only' \| 'cooldown'`. zaileys replies nothing — see [Guards](/commands#guards-and-command-blocked). |
73
+
|`command-error`|`{ command, error, ctx }`| A command handler threw. Listening takes ownership, so zaileys stops logging it itself. |
74
+
|`command-not-found`|`{ command, message }`| A prefixed message matched no registered command. |
75
+
66
76
### Inbound messages
67
77
68
78
These deliver a rich [message context](#the-message-context) object — the same shape across every message type. The `media` accessor is populated only for media kinds.
`ctx.category` holds that folder name, or `undefined` for a plugin sitting directly in the plugins
201
+
root. Setting `category` yourself always wins. See [Commands](/commands#describing-a-command) for
202
+
every field.
203
+
188
204
See [Commands](/commands) for the full command spec syntax, argument parsing, and `CommandContext`.
189
205
190
206
### `ctx.use(middleware)`
@@ -237,7 +253,8 @@ leaked listeners, commands, or middleware.
237
253
|`client`|`Client`| The full `Client` instance. Call any client method directly from here. |
238
254
|`logger`|`Logger \| undefined`| The client's logger instance. May be `undefined` if logging is disabled. |
239
255
|`pluginDir`|`string`| Absolute path to the directory containing this plugin file. Useful for loading sibling assets (e.g. JSON config, image files). |
240
-
|`command(spec, handler)`|`void`| Register a command. Tracked — auto-removed on unload. |
256
+
|`category`|`string \| undefined`| The subfolder this plugin lives in, e.g. `'group'` for `plugins/group/kick.ts`. `undefined` for a plugin in the plugins root. Commands default their `category` to it. |
257
+
|`command(spec, handler)`|`void`| Register a command. `spec` is a pipe string or a [command object](/commands#describing-a-command). Tracked — auto-removed on unload. |
241
258
|`use(middleware)`|`void`| Register command middleware. Tracked — auto-removed on unload. |
242
259
|`on(event, handler)`|`() => void`| Subscribe to a client event. Returns an unsubscribe fn. Tracked — auto-removed on unload. |
243
260
|`once(event, handler)`|`() => void`| Like `on` but fires once. Returns an unsubscribe fn. Tracked — auto-removed on unload. |
0 commit comments