mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +00:00
voice: Example should use JoinChannelAndSpeak
This commit is contained in:
parent
2d3bf2974a
commit
85619b2976
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue