**Improve event handling with new music and queue updates**
Added new `MusicEvent` types, including `TRACK_ERROR`, `TRACK_STUCK`, and `PLAYER_POSITION`, providing enhanced diagnostics and feedback. Improved queue mutation notifications by introducing granular events like `added`, `removed`, `moved`, `cleared`, and `shuffled`. Updated tests and documentation to reflect the changes, ensuring consistency and clarity across the event system.
This commit is contained in:
1 parent
75b495b08c
commit
87ba09b001
9 files changed
+336
-20
No files matched your search
@@ -91,6 +91,21 @@ Key points:
|
||||
`TaskManager.getInstance().handle(context)`.
|
||||
- **`null` contexts** (bot messages, consumer-only events) are simply not routed anywhere.
|
||||
|
||||
## Webhook music events
|
||||
|
||||
`MusicEvent` instances are delivered by `WebhookDispatcher`. Every event carries `type`, `guildId`,
|
||||
`timestamp` and `seq`; the payloads of the queue and player events are:
|
||||
|
||||
| Type | Payload |
|
||||
|---|---|
|
||||
| `QUEUE_UPDATED` | `size` (int), `change` (`added`/`removed`/`moved`/`cleared`/`shuffled`), `items` (list). Each item has `index` (0-based position, before the mutation for removals), `identifier`, `title`, `uri`, `requesterId`. `moved` items also carry `fromIndex` and `toIndex`. `cleared` and `shuffled` have an empty `items` (reload the queue on `shuffled`). |
|
||||
| `QUEUE_SHUFFLED` | `size` |
|
||||
| `TRACK_ERROR` | `track` (`identifier`, `title`, `author`, `length`, `uri`, `artworkUrl`), `message`, `severity` |
|
||||
| `TRACK_STUCK` | `track` (same fields as above), `thresholdMs` |
|
||||
| `PLAYER_POSITION` | `position` (ms), `timestamp` (node time, epoch ms), `connected`, `ping` (ms). Sent from Lavalink `PlayerUpdateEvent`, at most once every 5 seconds per guild and only while a track is playing. |
|
||||
|
||||
`size` in `QUEUE_UPDATED` is unchanged, so existing consumers keep working.
|
||||
|
||||
## Extending the event system
|
||||
|
||||
To handle a new event type:
|
||||
|
||||
Reference in new issue
Block a user