From 85619b2976e3d5dcd9193aadb0e0c03c6d5c793b Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 18 Jan 2022 18:22:27 -0800 Subject: [PATCH] voice: Example should use JoinChannelAndSpeak --- voice/session_example_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/voice/session_example_test.go b/voice/session_example_test.go index e96bbd6..01f4e80 100644 --- a/voice/session_example_test.go +++ b/voice/session_example_test.go @@ -4,6 +4,8 @@ import ( "context" "io" "log" + "os" + "os/signal" "testing" "github.com/diamondburned/arikawa/v3/discord" @@ -34,12 +36,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() @@ -49,10 +54,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) // Start writing Opus frames. for {