MIA
⛺ Moonlink.js - Imagine a Music Applicatiomextended-salmon
Music not playing but connecting
Hey there! My music doesn't play when connecting. I think it's because I do not have a raw event. I'm not using discordjs or any library, I have a custom implementation. Any clue how I could get the info needed to play music without the raw event or make something similar?
extended-salmon•425d ago
For extra context, I tried pushing up voice state events but that doesn't seem to work.
1Lucas1.apk•425d ago
Hello eralyne, you can manipulate the data to be sent by updateVoiceState
Let's say you don't have data, you can create the parameters to be treated internally
let's say
You treat the data out, then throw it to the updateVoiceState
If you use ws you can put it in the message received by the discord api gateway
extended-salmon•425d ago
This is what I've tried to push up
extended-salmon•425d ago
I just tried which didn't seem to work. What exact info is updateVoiceState eexpecting?
1Lucas1.apk•425d ago
You have to specify the events
I'll do it here and send it to you
@Eralyne What data does data receive, could you print it and send it to me
extended-salmon•425d ago
wise-white•425d ago
GG @Eralyne, you just advanced to level 1!
1Lucas1.apk•425d ago
he does not specify which date he receives?
extended-salmon•425d ago
oh, this is already filtered
So this is in my voiceStateUpdate handler
1Lucas1.apk•425d ago
say this example?
extended-salmon•425d ago
1 sec let me get the raw data
1Lucas1.apk•425d ago
There are two essential events
VOICE_SERVER_UPDATE, VOICE_STATE_UPDATE
extended-salmon•425d ago
Yeah, it's just the "d" portion stringified, I don't have any other portion of the gateway payload except the name of the event. Like I know this data is associated with VOICE_STATE_UPDATE and if I get VOICE_SERVER_UPDATE, I know that as well
1Lucas1.apk•425d ago
if you can spell out the "t" it will work
{ t: "event", d: {} }
extended-salmon•425d ago
So only t and d are needed?
1Lucas1.apk•425d ago
Yes
t to identify the event
d the event data
extended-salmon•425d ago
Hmm, doesn't seem to work
extended-salmon•425d ago
let me try one more thing
1Lucas1.apk•425d ago
It has to be both
If you play Moonlink it will identify the data as if it were this
extended-salmon•425d ago
I have it in server update as well
1Lucas1.apk•425d ago
try to explain better
There are 2 events (each event has its date )
The t is used to identify
updateVoiceState has ifs asking which event is which
If it is not the two events it ignores by name
If it is an event that is necessary, it will pick up and store it for the lavalink connections
extended-salmon•425d ago
Yes, I get that. But as you can see here, my t is one of those
1Lucas1.apk•425d ago
How do you make the connection?
With the discord api
extended-salmon•425d ago
I have an external gateway that sends events to my client and then I reply when needed with ws
wise-white•425d ago
GG @Eralyne, you just advanced to level 2!
extended-salmon•425d ago
This is my response
extended-salmon•425d ago
It works enough to make it connect to the channel
1Lucas1.apk•425d ago
I also thought about using some ifs to know what data you have to create a name
I'll see what data is and do the if
extended-salmon•425d ago
I see your updateVoiceState function, maybe the issue of it not playing is not this
extended-salmon•425d ago
This is what I send
extended-salmon•425d ago
Maybe it's an issue with my lavalink process?
1Lucas1.apk•425d ago
?eval let data = { endpoint: 'aaa', guild_id: 'aaa', token: 'aaa' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : event_name = null;
data?.session_id && data?.guild_id && data?.channel_id && data?.mute && data?.deaf ? event_name = 'VOICE_STATE_UPDATE' : event_name = null;
if (!event_name) return;
event_name
sunny-green•425d ago
1Lucas1.apk•425d ago
Wait, I'm not done yet
{
"channel_id": "157733188964188161",
"user_id": "80351110224678912",
"session_id": "90326bd25d71d39b9ef95b299e3872ff",
"deaf": false,
"mute": false,
"self_deaf": false,
"self_mute": true,
"suppress": false,
"request_to_speak_timestamp": "2021-03-31T18:45:31.297561+00:00"
}
?eval let data = { endpoint: 'aaa', guild_id: 'aaa', token: 'aaa' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : event_name = null;
data?.session_id && data?.guild_id && data?.channel_id && data?.mute && data?.deaf ? event_name = 'VOICE_STATE_UPDATE' : event_name = null;
if (!event_name) return;
event_name
bot died
extended-salmon•425d ago
I took a look to see how far the code reaches. It goes through the entire updateVoiceState method
extended-salmon•425d ago
But it fails at attemptConnection
extended-salmon•425d ago
one of either players or voiceServer do not seem to exist
1Lucas1.apk•425d ago
?eval let data = { endpoint: 'aaa', guild_id: 'aaa', token: 'aaa' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : event_name = null;
data?.session_id && data?.guild_id && data?.channel_id && data?.mute && data?.deaf ? event_name = 'VOICE_STATE_UPDATE' : event_name = null;
if (!event_name) return;
event_name
sunny-green•425d ago
1Lucas1.apk•425d ago
?eval let data = { endpoint: 'aaa', guild_id: 'aaa', token: 'aaa' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : event_name = null;
data?.session_id && data?.guild_id && data?.channel_id && data?.mute && data?.deaf ? event_name = 'VOICE_STATE_UPDATE' : event_name = null;
event_name
extended-salmon•425d ago
players exists, voiceServer for the guildId does not exist.
sunny-green•425d ago
extended-salmon•425d ago
I don't think this is necessary. This bloats the code. Just specify what payload has to look like in the documentation. My implementation goes through voiceStateUpdate just fine now
1Lucas1.apk•425d ago
it's just a test
Because he didn't get it right
When the received event is the state' it saves the information to join with the server at the end
extended-salmon•425d ago
Okay, I think I know my issue. I never get the Voice_Server_Update event
Since I never get that on initial join, it's not going to be mapped
1Lucas1.apk•425d ago
There's no way to make him play the events without filtering them
extended-salmon•425d ago
Not saying to filter them. I'm just saying for some reason my gateway doesn't get that event
1Lucas1.apk•425d ago
Try to see where they are received, because normally discord sends events
sunny-green•425d ago
1Lucas1.apk•425d ago
?eval let data = { endpoint: 'aaa', guild_id: 'aaa', token: 'aaa' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : data;
data?.session_id && data?.guild_id && data?.channel_id && data?.mute && data?.deaf ? event_name = 'VOICE_STATE_UPDATE' : data ;
event_name
sunny-green•425d ago
1Lucas1.apk•425d ago
?eval let data = { session_id: 'aba' }
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : data;
data?.session_id ? event_name = 'VOICE_STATE_UPDATE' : data ;
event_name
sunny-green•425d ago
1Lucas1.apk•425d ago
let event_name = null;
data?. token && data?.endpoint && data?.guild_id ? event_name = 'VOICE_SERVER_UPDATE' : data;
data?.session_id ? event_name = 'VOICE_STATE_UPDATE' : data ;
This is a check with the necessary properties in the events
extended-salmon•425d ago
what if endpoint is null for voice_server?
That usually indicates that the bot needs to wait for the voice server to be reallocated
It won't pass your check in this case
1Lucas1.apk•425d ago
hmmmm
I don't think it will change, within Moonlink it usually only uses it once
It takes this data together and sends it to lavalink, then lavalink establishes a connection
extended-salmon•425d ago
Yeah, it seems my issue is that I just don't get the voice server update event. Guess I'll investigate that. I can fake its data but probably not good to do. Thanks for helping me isolate the issue
1Lucas1.apk•425d ago
have a great day :D
Want results from more Discord servers?
More Posts