-
-
Notifications
You must be signed in to change notification settings - Fork 26
5. Websocket
ByteBlaze provide an event system that track player activity of the bot through websocket. This is for developing dashboard with an easy way for middle developer.
This doc will explain, providing example clearly for each event
Note: If the field title have ?
, that means data can nullable
You can establish a WebSocket connection against the path /v1/websocket
When opening a websocket connection, you must supply 2 required headers:
Header Name | Description |
---|---|
authorization | The password you set in your ByteBlaze config |
guild-id | The guild id which you want bot to open websocket |
Note: If you use the guild id that not exist on byteblaze to connect websocket, it won't send any events
Dispatched when a player is created.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
Example Payload
{
"op": "playerCreate",
"guild": "1084918771967344662",
}
Dispatched when a player is destroyed.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
Example Payload
{
"op": "playerDestroy",
"guild": "1084918771967344662",
}
Dispatched when a player is paused.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
Example Payload
{
"op": "playerPause",
"guild": "1084918771967344662",
}
Dispatched when a player is resume.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
Example Payload
{
"op": "playerResume",
"guild": "1084918771967344662",
}
Dispatched when a player is update.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
position | number | The current position of this track |
Example Payload
{
"op": "playerUpdate",
"guild": "1084918771967344662",
"position": 5880,
}
Dispatched when a track in player is started.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
data? | Track object | The track info of now playing track |
Example Payload
{
"op": "trackStart",
"guild": "1084918771967344662",
"data": {
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
}
}
Dispatched when a track in player is ended.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
data? | Track object | The track info of previous track |
mode | Mode string | The end mode of this event |
Example Payload
{
"op": "trackEnd",
"guild": "1084918771967344662",
"data": {
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
}
}
Dispatched when a memeber is joined.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
userId | string | The discord id of memeber that join the voice |
Example Payload
{
"op": "memberJoin",
"guild": "1084918771967344662",
"userId": "898728768791789628",
}
Dispatched when a memeber is leaved.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
userId | string | The discord id of memeber that leave the voice |
Example Payload
{
"op": "memberLeave",
"guild": "1084918771967344662",
"userId": "898728768791789628",
}
Dispatched when a player volume is changed.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
volume | number | The changed player volume |
Example Payload
{
"op": "playerVolume",
"guild": "1084918771967344662",
"volume": 90,
}
Dispatched when a player volume is changed.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
mode | Mode string | The changed player loop mode |
Example Payload
{
"op": "playerLoop",
"guild": "1084918771967344662",
"mode": "queue",
}
Dispatched when a player queue is cleared.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
Example Payload
{
"op": "playerClearQueue",
"guild": "1084918771967344662",
}
Dispatched when a player track from queue is removed.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
data | Track object | The track info |
index | number | The index for removed track in array |
Example Payload
{
"op": "playerQueueRemove",
"guild": "1084918771967344662",
"data": {
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
},
"index": 4
}
Dispatched when a player track from queue is inserted.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
data | Track object | The track info |
index | number | The index for inserted track in array |
Example Payload
{
"op": "playerQueueInsert",
"guild": "1084918771967344662",
"data": {
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
},
"index": 4
}
Dispatched when a player track from queue is inserted.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
queue | Track array | The track queue info that shuffered |
Example Payload
{
"op": "playerQueueShuffle",
"guild": "1084918771967344662",
"queue": [
{
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
}
],
}
Dispatched when a player skip to another index of queue.
Field | Type | Description |
---|---|---|
op | string | The event name |
guild | string | The guild that have this event |
queue | Track array | The track queue info that shuffered |
Example Payload
{
"op": "playerQueueSkip",
"guild": "1084918771967344662",
"queue": [
{
"title": "2Pac - Dear Mama",
"uri": "https://www.youtube.com/watch?v=Mb1ZvUDvLDY",
"length": 276000,
"thumbnail": "https://i.ytimg.com/vi/Mb1ZvUDvLDY/maxresdefault.jpg",
"author": "2PacVEVO",
"requester": {
"id": "898728768791789628",
"username": "rainyxeon",
"globalName": "rainy w/π§",
"defaultAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp?size=128",
}
}
],
}
Thanks for reading! Below are my social media!
- Discord: rainyxeon
- Facebook: https://www.facebook.com/rainy.xeon/
- Email: [email protected]
- Instagram: @rainy.xeon