Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

4. [BETA] Websocket

XeonE52680v3 edited this page Aug 24, 2023 · 1 revision

Introduction

If you're reading this doc, you're a good developer and hardcore user :D Basically, I will provide some API method, response and how to use it.

Setting up

To use ws in ByteBlaze, you need to enable it on application.yml file like this one:

...
  WEBSOCKET:
    enable: true
    port: 8080
    auth: false
    trusted: ['http://localhost:3000']
...

If you want to secure connect and want your own host only, enable auth and paste your host url string inside trusted array.

Method (Message)

join

Example Request:

{ 
    "message": "join",
    "guild": "1027945618347397220",
    "user": "898728768791789628"
}

Example Response:

{
    "op": "player_create",
    "guild": "1027945618347397220"
}

destroy

Example Request:

{ 
    "message": "destroy",
    "guild": "1027945618347397220"
}

Example Response:

{
    "op": "player_destroy",
    "guild": "1027945618347397220"
}

add (Query)

Example Request:

{
    "message": "add",
    "guild": "1027945618347397220",
    "query": "yorushika",
    "user": "898728768791789628"
}

Example Response (Sent 2 times):

{
    "op": "player_start",
    "guild": "1027945618347397220",
    "current": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}
{
    "op": "player_queue",
    "guild": "1027945618347397220",
    "queue": [
        {
            "title": "Yorushika - \"Say It.\" (Music Video)",
            "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
            "length": 244000,
            "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        },
        {
            "title": "ヨルシカ - 斜陽",
            "uri": "https://www.youtube.com/watch?v=bqigIHMComE",
            "length": 207000,
            "thumbnail": "https://img.youtube.com/vi/bqigIHMComE/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        }
    ]
}

pause

Example Request:

{
    "message": "pause",
    "guild": "1027945618347397220"
}

Example Response:

{
    "op": "pause_track",
    "guild": "1027945618347397220"
}

resume

Example Request:

{
    "message": "resume",
    "guild": "1027945618347397220"
}

Example Response:

{
    "op": "resume_track",
    "guild": "1027945618347397220"
}

search

Example Request:

{
    "message": "search",
    "guild": "1027945618347397220",
    "query": "yorushika"
}

Example Response:

{
    "op": "search",
    "guild": "1027945618347397220",
    "queue": [
        {
            "resolvedBySource": false,
            "track": "QAABDQIANuODqOODq+OCt+OCqyAt44CM6KiA44Gj44Gm44CC44CNLyBZb3J1c2hpa2EgLSAiU2F5IHRvIgALTG9zdCBzYW1wbGUAAAAAAAO3AQBxTzpodHRwczovL2FwaS12Mi5zb3VuZGNsb3VkLmNvbS9tZWRpYS9zb3VuZGNsb3VkOnRyYWNrczozMzA3MDY4OTMvMjc5NmIzNGYtNDEwYi00MjY4LWExZDctYjIzZWY5NzljZTM1L3N0cmVhbS9obHMAAQA0aHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS8zZDZ3eXRkZHhqZTcveW9ydXNoaWthLXNheS10bwAKc291bmRjbG91ZAAAAAAAAAAA",
            "sourceName": "soundcloud",
            "title": "ヨルシカ -「言って。」/ Yorushika - \"Say to\"",
            "uri": "https://soundcloud.com/3d6wytddxje7/yorushika-say-to",
            "identifier": "O:https://api-v2.soundcloud.com/media/soundcloud:tracks:330706893/2796b34f-410b-4268-a1d7-b23ef979ce35/stream/hls",
            "isSeekable": true,
            "isStream": false,
            "author": "Lost sample",
            "length": 243457,
            "realUri": "https://soundcloud.com/3d6wytddxje7/yorushika-say-to",
            "requester": null
        },
        {
            "resolvedBySource": false,
            "track": "QAABFAIAOVlvcnVzaGlrYS0gSGl0Y2hjb2NrICjjg6jjg6vjgrfjgqsgLSDjg5Ljg4Pjg4HjgrPjg4Pjgq8gKQANbm90IGEgd2VlYWJvbwAAAAAAA31yAHFPOmh0dHBzOi8vYXBpLXYyLnNvdW5kY2xvdWQuY29tL21lZGlhL3NvdW5kY2xvdWQ6dHJhY2tzOjQyODQ0NTg2NC9iMjFmYTJjMi1kNTNhLTRmZWUtYTE1My1jNmFjZmIzNzYwY2Yvc3RyZWFtL2hscwABADZodHRwczovL3NvdW5kY2xvdWQuY29tL3NlY29uZC1jb3B5L3lvcnVzaGlrYS1oaXRjaGNvY2sACnNvdW5kY2xvdWQAAAAAAAAAAA==",
            "sourceName": "soundcloud",
            "title": "Yorushika- Hitchcock (ヨルシカ - ヒッチコック )",
            "uri": "https://soundcloud.com/second-copy/yorushika-hitchcock",
            "identifier": "O:https://api-v2.soundcloud.com/media/soundcloud:tracks:428445864/b21fa2c2-d53a-4fee-a153-c6acfb3760cf/stream/hls",
            "isSeekable": true,
            "isStream": false,
            "author": "not a weeaboo",
            "length": 228722,
            "realUri": "https://soundcloud.com/second-copy/yorushika-hitchcock",
            "requester": null
        }
    ]
}

skip

Example Request:

{
    "message": "skip",
    "guild": "1027945618347397220"
}

Example Response (send 2 times. send the next track):

{
    "op": "player_end",
    "guild": "1027945618347397220",
    "track": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}
{
    "op": "player_start",
    "guild": "1027945618347397220",
    "current": {
        "title": "ヨルシカ - 斜陽",
        "uri": "https://www.youtube.com/watch?v=bqigIHMComE",
        "length": 207000,
        "thumbnail": "https://img.youtube.com/vi/bqigIHMComE/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}

previous

Example Request:

{
    "message": "previous",
    "guild": "1027945618347397220"
}

Example Response: (sent 3 times, send the previous track with end track)

{
    "op": "previous_track",
    "guild": "1027945618347397220",
    "track": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}
{
    "op": "player_end",
    "guild": "1027945618347397220",
    "track": {
        "title": "ヨルシカ - 斜陽",
        "uri": "https://www.youtube.com/watch?v=bqigIHMComE",
        "length": 207000,
        "thumbnail": "https://img.youtube.com/vi/bqigIHMComE/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}
{
    "op": "player_start",
    "guild": "1027945618347397220",
    "current": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    }
}

status

Example Request:

{
    "message": "status",
    "guild": "1027945618347397220",
    "user": "898728768791789628"
}

Example Response:

{
    "op": "status",
    "guild": "1027945618347397220",
    "loop": "none",
    "member": true,
    "pause": false,
    "current": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    },
    "queue": [
        {
            "title": "Yorushika - Just a Sunny Day for You (Music Video)",
            "uri": "https://www.youtube.com/watch?v=-VKIqrvVOpo",
            "length": 200000,
            "thumbnail": "https://img.youtube.com/vi/-VKIqrvVOpo/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        },
        {
            "title": "Yorushika - That's Why I Gave Up on Music (MUSIC VIDEO)",
            "uri": "https://www.youtube.com/watch?v=KTZ-y85Erus",
            "length": 247000,
            "thumbnail": "https://img.youtube.com/vi/KTZ-y85Erus/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        }
    ]
}

status.playing

Example Request:

{
    "message": "status.playing",
    "guild": "1027945618347397220"
}

Example Response:

{ 
    "op": "player_destroy", 
    "guild": "1027945618347397220"
}

or

{ 
    "op": "player_create", 
    "guild": "1027945618347397220"
}

status.pause

Example Request:

{
    "message": "status.pause",
    "guild": "1027945618347397220"
}

Example Response:

{
    "op": "resume_track",
    "guild": "1027945618347397220"
}

resume

Example Request:

{
    "message": "status.member",
    "guild": "1027945618347397220",
    "user": "898728768791789628"
}

Example Response:

{
    "op": "voice_state_update_join",
    "guild": "1027945618347397220"
}

or

{
    "op": "voice_state_update_leave",
    "guild": "1027945618347397220"
}

status.loop

Example Request:

{
    "message": "status.loop",
    "guild": "1027945618347397220"
}

Example Response:

{
    "op": "loop_queue",
    "guild": "1027945618347397220",
    "status": "none"
}

loop

Example Request:

  • Example 1 (Tell the current status):
{
    "message": "loop",
    "guild": "1027945618347397220",
    "status": "none"
}
  • Example 2 (Set directly):
{
    "message": "loop",
    "guild": "1027945618347397220",
    "mode": "none"
}

Example Response:

{
    "guild": "1027945618347397220",
    "op": "loop_queue",
    "status": "track"
}

status.current_track

Example Request:

{
    "message": "status.current_track",
    "guild": "1027945618347397220"
}

Example Response: (Send the next track)

{
    "op": "player_start",
    "guild": "1027945618347397220",
    "current": {
        "title": "Yorushika - \"Say It.\" (Music Video)",
        "uri": "https://www.youtube.com/watch?v=F64yFFnZfkI",
        "length": 244000,
        "thumbnail": "https://img.youtube.com/vi/F64yFFnZfkI/hqdefault.jpg",
        "author": "ヨルシカ / n-buna Official",
        "requester": {
            "guildId": "1027945618347397220",
            "joinedTimestamp": 1665151733736,
            "premiumSinceTimestamp": null,
            "nickname": null,
            "pending": false,
            "communicationDisabledUntilTimestamp": null,
            "userId": "898728768791789628",
            "avatar": null,
            "flags": 0,
            "displayName": "RainyXeon </>",
            "roles": [
                "1027945618347397220"
            ],
            "avatarURL": null,
            "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
        }
    },
    "queue": [
        {
            "title": "Yorushika - Just a Sunny Day for You (Music Video)",
            "uri": "https://www.youtube.com/watch?v=-VKIqrvVOpo",
            "length": 200000,
            "thumbnail": "https://img.youtube.com/vi/-VKIqrvVOpo/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        },
        {
            "title": "Yorushika - That's Why I Gave Up on Music (MUSIC VIDEO)",
            "uri": "https://www.youtube.com/watch?v=KTZ-y85Erus",
            "length": 247000,
            "thumbnail": "https://img.youtube.com/vi/KTZ-y85Erus/hqdefault.jpg",
            "author": "ヨルシカ / n-buna Official",
            "requester": {
                "guildId": "1027945618347397220",
                "joinedTimestamp": 1665151733736,
                "premiumSinceTimestamp": null,
                "nickname": null,
                "pending": false,
                "communicationDisabledUntilTimestamp": null,
                "userId": "898728768791789628",
                "avatar": null,
                "flags": 0,
                "displayName": "RainyXeon </>",
                "roles": [
                    "1027945618347397220"
                ],
                "avatarURL": null,
                "displayAvatarURL": "https://cdn.discordapp.com/avatars/898728768791789628/734d8a64053d0e4d4c7d32bfd4c2079e.webp"
            }
        }
    ]
}