pincer.objects.events.voice   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 160
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 42
dl 0
loc 160
rs 10
c 0
b 0
f 0
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from dataclasses import dataclass
7
from enum import Enum, auto
8
from typing import TYPE_CHECKING
9
10
from ...utils.api_object import APIObject, GuildProperty
11
12
if TYPE_CHECKING:
13
    from typing import Optional, List
14
15
    from ...utils.snowflake import Snowflake
16
17
18
@dataclass(repr=False)
19
class VoiceServerUpdateEvent(APIObject, GuildProperty):
20
    """Sent when a guild's voice server is updated.
21
    This is sent when initially connecting to voice,
22
    and when the current voice instance fails over to a new server.
23
24
    Attributes
25
    ----------
26
    token: :class:`str`
27
        Voice connection token
28
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
29
        The guild this voice server update is for
30
    endpoint: Optional[:class:`str`]
31
        The voice server host
32
    """
33
34
    token: str
35
    guild_id: Snowflake
36
    endpoint: Optional[str] = None
37
38
39
@dataclass(repr=False)
40
class VoiceChannelSelectEvent(APIObject, GuildProperty):
41
    """
42
    Sent when the client joins a voice channel
43
44
    Attributes
45
    ----------
46
    channel_id : Optional[:class:`Snowflake`]
47
        id of channel
48
49
    guild_id : Optional[:class:`Snowflake`]
50
        id of guild
51
    """
52
53
    channel_id: Optional[Snowflake] = None
54
    guild_id: Optional[Snowflake] = None
55
56
57
class VoiceConnectionStates(Enum):
58
    """
59
    Attributes
60
    ----------
61
    DISCONNECTED : :class:`str`
62
        TCP disconnected
63
64
    AWAITING_ENDPOINT : :class:`str`
65
        Waiting for voice endpoint
66
67
    AUTHENTICATING : :class:`str`
68
        TCP authenticating
69
70
    CONNECTING : :class:`str`
71
        TCP connecting
72
73
    CONNECTED : :class:`str`
74
        TCP connected
75
76
    VOICE_DISCONNECTED : :class:`str`
77
        TCP connected, Voice disconnected
78
79
    VOICE_CONNECTING : :class:`str`
80
        TCP connected, Voice connecting
81
82
    VOICE_CONNECTED : :class:`str`
83
        TCP connected, Voice connected
84
85
    NO_ROUTE : :class:`str`
86
        No route to host
87
88
    ICE_CHECKING : :class:`str`
89
        WebRTC ice checking
90
91
    """
92
93
    DISCONNECTED = auto()
94
    AWAITING_ENDPOINT = auto()
95
    AUTHENTICATING = auto()
96
    CONNECTING = auto()
97
    CONNECTED = auto()
98
    VOICE_DISCONNECTED = auto()
99
    VOICE_CONNECTING = auto()
100
    VOICE_CONNECTED = auto()
101
    NO_ROUTE = auto()
102
    ICE_CHECKING = auto()
103
104
105
@dataclass(repr=False)
106
class VoiceConnectionStatusEvent(APIObject):
107
    """
108
    Sent when the client's voice connection status changes
109
110
    state : :class:`VoiceConnectionStates`
111
        one of the voice connection states listed below
112
113
    hostname : :class:`str`
114
        hostname of the connected voice server
115
116
    pings : List[:class:`int`]
117
        last 20 pings (in ms)
118
119
    average_ping : :class:`int`
120
        average ping (in ms)
121
122
    last_ping : :class:`int`
123
        last ping (in ms)
124
125
    """
126
127
    state: VoiceConnectionStates
128
    hostname: str
129
    pings: List[int]
130
    average_ping: int
131
    last_ping: int
132
133
134
@dataclass(repr=False)
135
class SpeakingStartEvent(APIObject):
136
    """
137
    Sent when a user in a subscribed voice channel speaks
138
139
    Attributes
140
    ----------
141
    user_id : :class:`Snowflake`
142
        id of user who started speaking
143
    """
144
145
    user_id: Snowflake
146
147
148
@dataclass(repr=False)
149
class SpeakingStopEvent(APIObject):
150
    """
151
    Sent when a user in a subscribed voice channel stops speaking
152
153
    Attributes
154
    ----------
155
    user_id : :class:`Snowflake`
156
        id of user who stopped speaking
157
    """
158
159
    user_id: Snowflake
160