Hello,
I’ve recently begun work on a project to stream audio from Syrinscape online via a Discord bot using Discord.js.
I’ve made some progress so far, and the github repo can be found here for anyone interested: https://github.com/jmccuen/SyrinscapeDiscordBot (MIT License)
Right now, it will connect to the websocket endpoint, register the device and link it to the game. The websocket stream then received JSON messages with the .ogg files.
Once you connect to the websocket endpoint, you can register your device by sending the following two messages:
{
“message”: “register”,
“device_uuid”: “” //add the auth UUID from your player here
};
{
“message”: “request_linkup”,
“params”: {
“device_name”: “SyrinscapeBot”,
“player_version”: “1.4.6-20200115”,
“is_stopped”: false
}
};
and you will begin to see json response messages with mood elements such as:
{
“stream”:true,
“s_id”:“sample_322451”,
“url”:url.ogg,
“file”:“556d0aaf37d249144b7cca312acdd520.ogg”,
“id”:“playlist_2824871”,
“len”:“132.26”,
“name”:“Environmental systems hum”,
“e_id”:“element_486783”
}
From here, we can parse the .ogg files and stream them in to the Discord voice channel – but this seems a little odd to me, I would’ve expected the audio to just stream over the WebSocket channel (and be mixed on the server), so I thought I would post here first to see if anyone could confirm this is the case.
Let me know if anyone has any thoughts and feel free to submit a pull request directly to the repo.
Thanks!
Edit: You can get it to play a single element pretty easily by just passing the .ogg file url into the Discord dispatcher’s play method when the message comes in, by the way – there just seems to be a lot of complicated logic around mixing the files.