8000 disgo/voice at master · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

voice

README.md

voice

Voice provides a package to connect and send/receive voice to/from discord servers. For Discords Docs on voice see here.

DAVE(E2EE) library options:

GoDave

Installation

go get github.com/disgoorg/godave/golibdave

Logging

Libdave uses a global logger which is set it slog.LevelError by default. You can change this by calling:

libdave.SetDefaultLogLoggerLevel(slog.LevelInfo)

or set your own logger:

libdave.SetDefaultLogLogger(yourLogger)

Dave-Go

Installation

go get github.com/thomas-vilte/dave-go

Usage

To send audio you need to create a voice connection. When using the bot.Client package you can use client.VoiceManager().CreateConn(guildID)

const (
    guildID = 12345
    channelID = 12345
)

client, err := disgo.New(token,
	bot.WithGatewayConfigOpts(gateway.WithIntents(gateway.IntentGuildVoiceStates)),
	bot.WithVoiceManagerConfigOpts(
		// for GoDave use this
		voice.WithDaveSessionCreateFunc(golibdave.NewSession),
		// for Dave-Go use this
		voice.WithDaveSessionCreateFunc(session.NewSession),
	),
)
// handle err

conn := client.VoiceManager().CreateConn(guildID)

err := conn.Open(context.TODO(), channelID, false, false)
// handle err

// set speaking flag
err := conn.SetSpeaking(ctx, voice.SpeakingFlagMicrophone)

// send opus frame
conn.UDP().Write(frame)

// close connection
conn.Close()

When using the voice package standalone you should create a voice manager. After this you can call voice.Manager.CreateConn(guildID). After this you should send a gateway.OpcodeVoiceStateUpdate packet to the gateway.

0