SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
697 stars 143 forks source link

Expose the session_id of a user's voice state #197

Open JohnnyMorganz opened 5 years ago

JohnnyMorganz commented 5 years ago

The session_id provided during VOICE_STATE_UPDATE for the authenticated user is required for playing voice using external software (eg. lavalink)

There should be a member property of voiceSessionId for the authenticated user, which can be passed on further Currently I have to use guild._voice_states[user.id].session_id in order to access this data, however _voice_states is an internal property and it is not recommend to access it this way

Examples of it being provided in other libraries: https://abal.moe/Eris/docs/VoiceState https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=voiceSessionID https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceClient.session_id

SinisterRectus commented 5 years ago

I don't mind doing this, but don't you also need the server_id, user_id, and token from the voice state update?

JohnnyMorganz commented 5 years ago

For my current use-case, that being integration with Lavalink, I haven't needed the other properties; the point at which I need the session id is during a VOICE_SERVER_UPDATE, which provides the guild_id/server_id, and the user_id is the authenticated bot (which I can retrieve from client.user.id). No mention of token either in the Lavalink Documentation.

However, it may very well be useful for someone else who is integrating voice in their own way.