github.com/diamondburned/arikawa/v2@v2.1.0/voice/voicegateway/events.go (about)

     1  package voicegateway
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"github.com/diamondburned/arikawa/v2/discord"
     7  )
     8  
     9  // OPCode 2
    10  // https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload
    11  type ReadyEvent struct {
    12  	SSRC        uint32   `json:"ssrc"`
    13  	IP          string   `json:"ip"`
    14  	Port        int      `json:"port"`
    15  	Modes       []string `json:"modes"`
    16  	Experiments []string `json:"experiments"`
    17  
    18  	// From Discord's API Docs:
    19  	//
    20  	// `heartbeat_interval` here is an erroneous field and should be ignored.
    21  	// The correct `heartbeat_interval` value comes from the Hello payload.
    22  
    23  	// HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
    24  }
    25  
    26  func (r ReadyEvent) Addr() string {
    27  	return r.IP + ":" + strconv.Itoa(r.Port)
    28  }
    29  
    30  // OPCode 4
    31  // https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-session-description-payload
    32  type SessionDescriptionEvent struct {
    33  	Mode      string   `json:"mode"`
    34  	SecretKey [32]byte `json:"secret_key"`
    35  }
    36  
    37  // OPCode 5
    38  type SpeakingEvent SpeakingData
    39  
    40  // OPCode 6
    41  // https://discord.com/developers/docs/topics/voice-connections#heartbeating-example-heartbeat-ack-payload
    42  type HeartbeatACKEvent uint64
    43  
    44  // OPCode 8
    45  // https://discord.com/developers/docs/topics/voice-connections#heartbeating-example-hello-payload-since-v3
    46  type HelloEvent struct {
    47  	HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
    48  }
    49  
    50  // OPCode 9
    51  // https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection-example-resumed-payload
    52  type ResumedEvent struct{}
    53  
    54  // OPCode 12
    55  // (undocumented)
    56  type ClientConnectEvent struct {
    57  	UserID    discord.UserID `json:"user_id"`
    58  	AudioSSRC uint32         `json:"audio_ssrc"`
    59  	VideoSSRC uint32         `json:"video_ssrc"`
    60  }
    61  
    62  // OPCode 13
    63  // Undocumented, existence mentioned in below issue
    64  // https://github.com/discord/discord-api-docs/issues/510
    65  type ClientDisconnectEvent struct {
    66  	UserID discord.UserID `json:"user_id"`
    67  }