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?
58 Replies
correct-apricotOP•2y ago
For extra context, I tried pushing up voice state events but that doesn't seem to work.
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
correct-apricotOP•2y ago
This is what I've tried to push up
correct-apricotOP•2y ago
I just tried which didn't seem to work. What exact info is updateVoiceState eexpecting?
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
correct-apricotOP•2y ago
GG @Eralyne, you just advanced to level 1!
he does not specify which date he receives?
correct-apricotOP•2y ago
oh, this is already filtered
So this is in my voiceStateUpdate handler
say this example?
correct-apricotOP•2y ago
1 sec let me get the raw data
There are two essential events
VOICE_SERVER_UPDATE, VOICE_STATE_UPDATE
correct-apricotOP•2y 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
if you can spell out the "t" it will work
{ t: "event", d: {} }
correct-apricotOP•2y ago
So only t and d are needed?
Yes
t to identify the event
d the event data
correct-apricotOP•2y ago
Hmm, doesn't seem to work
correct-apricotOP•2y ago
let me try one more thing
It has to be both
If you play Moonlink it will identify the data as if it were this
correct-apricotOP•2y ago
I have it in server update as well
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
correct-apricotOP•2y ago
Yes, I get that. But as you can see here, my t is one of those
How do you make the connection?
With the discord api
correct-apricotOP•2y ago
I have an external gateway that sends events to my client and then I reply when needed with ws
GG @Eralyne, you just advanced to level 2!
correct-apricotOP•2y ago
This is my response
correct-apricotOP•2y ago
It works enough to make it connect to the channel
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
correct-apricotOP•2y ago
I see your updateVoiceState function, maybe the issue of it not playing is not this
correct-apricotOP•2y ago
This is what I send
correct-apricotOP•2y ago
Maybe it's an issue with my lavalink process?
?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
conscious-sapphire•2y 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
correct-apricotOP•2y ago
I took a look to see how far the code reaches. It goes through the entire updateVoiceState method
correct-apricotOP•2y ago
But it fails at attemptConnection
correct-apricotOP•2y ago
one of either players or voiceServer do not seem to exist
?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
conscious-sapphire•2y 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
correct-apricotOP•2y ago
players exists, voiceServer for the guildId does not exist.
conscious-sapphire•2y ago
correct-apricotOP•2y 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
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
correct-apricotOP•2y 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
There's no way to make him play the events without filtering them
correct-apricotOP•2y ago
Not saying to filter them. I'm just saying for some reason my gateway doesn't get that event
Try to see where they are received, because normally discord sends events
conscious-sapphire•2y 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
conscious-sapphire•2y 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
conscious-sapphire•2y 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
correct-apricotOP•2y 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
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
correct-apricotOP•2y 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
have a great day :D