Skip to content

Commit

Permalink
Removed hardcoding voice port for endpoints, as this has been fixed b…
Browse files Browse the repository at this point in the history
…y Discord.
  • Loading branch information
Nekokatt committed Oct 2, 2020
1 parent 9e5121d commit b2304e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion hikari/emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def parse(cls, string: str, /) -> UnicodeEmoji:
UnicodeEmoji
The parsed UnicodeEmoji object.
"""

# Ensure validity.
for i, codepoint in enumerate(string, start=1):
unicodedata.name(codepoint)
Expand Down
16 changes: 7 additions & 9 deletions hikari/events/voice_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,26 @@ class VoiceServerUpdateEvent(VoiceEvent):
"""

raw_endpoint: str = attr.ib(repr=True)
"""Raw endpoint URL that Discord sent.
"""Raw endpoint URI that Discord sent.
!!! warning
This will always be wrong. See
https://github.com/discord/discord-api-docs/issues/2116
for more details.
This will not contain the scheme to use. Use the `endpoint` property
to get a representation that has this prepended.
Returns
-------
builtins.str
The incorrect endpoint URL for the voice gateway server to connect to.
A scheme-less endpoint URI for the endpoint to use for a new voice
websocket.
"""

@property
def endpoint(self) -> str:
"""URI for this voice server host, with the correct port and protocol.
"""URI for this voice server host, with the correct scheme prepended.
Returns
-------
builtins.str
The URI to use to connect to the voice gateway.
"""
# Discord have had this wrong for like 4 years, bleh.
uri, _, _ = self.raw_endpoint.rpartition(":")
return f"wss://{uri}:443"
return f"wss://{self.raw_endpoint}"
2 changes: 1 addition & 1 deletion tests/hikari/events/test_voice_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def event(self):
)

def test_endpoint_property(self, event):
assert event.endpoint == "wss://voice.discord.com:443"
assert event.endpoint == "wss://voice.discord.com:123"

0 comments on commit b2304e4

Please sign in to comment.