1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 09:12:53 +00:00

voice: Example should use JoinChannelAndSpeak

This commit is contained in:
diamondburned 2022-01-18 18:22:27 -08:00
parent c8f72547f7
commit 40ff267a74
No known key found for this signature in database
GPG key ID: D78C4471CE776659

View file

@ -3,6 +3,8 @@ package voice_test
import (
"context"
"log"
"os"
"os/signal"
"testing"
"github.com/diamondburned/arikawa/v3/discord"
@ -31,12 +33,15 @@ func TestNoop(t *testing.T) {
}
func ExampleSession() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
s := state.New("Bot " + token)
// This is required for bots.
voice.AddIntents(s)
if err := s.Open(context.TODO()); err != nil {
if err := s.Open(ctx); err != nil {
log.Fatalln("failed to open gateway:", err)
}
defer s.Close()
@ -46,10 +51,10 @@ func ExampleSession() {
log.Fatalln("failed to create voice session:", err)
}
if err := v.JoinChannel(context.TODO(), channelID, false, false); err != nil {
if err := v.JoinChannelAndSpeak(ctx, channelID, false, false); err != nil {
log.Fatalln("failed to join voice channel:", err)
}
defer v.Leave(context.TODO())
defer v.Leave(ctx)
if err := testdata.WriteOpus(v, "testdata/nico.dca"); err != nil {
log.Fatalln("failed to write opus:", err)