Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to bypass builtin voice connection management #577

Closed
foxbot opened this issue Aug 23, 2018 · 0 comments
Closed

Allow users to bypass builtin voice connection management #577

foxbot opened this issue Aug 23, 2018 · 0 comments
Milestone

Comments

@foxbot
Copy link
Contributor

foxbot commented Aug 23, 2018

By allowing users to bypass discordgo's builtin voice connection management, they can use third-party voice solutions such as Lavalink

The only changes necessary to the lib would be adding a public function to discordgo.Session to send an op4 to Discord to initiate the voice handshake and return a VOICE_SERVER_UPDATE. The library already exposes an event for VOICE_SERVER_UPDATE with the proper fields; however, the library also intercepts this event and uses it to complete its own voice connection.

This would be a pretty simple change, and should only end up being something like

func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error) {
	// ripped from https://github.com/bwmarrin/discordgo/blob/master/wsapi.go#L598
	
	// Send the request to Discord that we want to join the voice channel
	data := voiceChannelJoinOp{4, voiceChannelJoinData{&gID, &cID, mute, deaf}}
	s.wsMutex.Lock()
	err = s.wsConn.WriteJSON(data)
	s.wsMutex.Unlock()
	if err != nil {
		return
	}
}
@iopred iopred closed this as completed in a089b52 Nov 2, 2018
@bwmarrin bwmarrin added this to the v0.19.0 milestone Aug 27, 2019
ErikMcClure pushed a commit to ErikMcClure/discordgo that referenced this issue Aug 4, 2020
This resolves bwmarrin#577.

ChannelVoiceJoinManual is a wrapper over sending an OP4 to Discord, for
initiating a voice server connection. The library's builtin voice
connection management locks/maps are skipped, and the library will not
attempt to manage this voice connection.

Users are expected to hook the VoiceServerUpdate event and forward the
data to an outside voice manager, such as Lavalink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants