From b2304e4f1963643767556e2ea518db5aeaa35e97 Mon Sep 17 00:00:00 2001 From: Nekokatt Date: Fri, 2 Oct 2020 15:29:54 +0100 Subject: [PATCH] Removed hardcoding voice port for endpoints, as this has been fixed by Discord. --- hikari/emojis.py | 1 - hikari/events/voice_events.py | 16 +++++++--------- tests/hikari/events/test_voice_events.py | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hikari/emojis.py b/hikari/emojis.py index 04a70ed4d2..bfa72f8fe4 100644 --- a/hikari/emojis.py +++ b/hikari/emojis.py @@ -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) diff --git a/hikari/events/voice_events.py b/hikari/events/voice_events.py index 6ab3e1cd71..b29eecec90 100644 --- a/hikari/events/voice_events.py +++ b/hikari/events/voice_events.py @@ -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}" diff --git a/tests/hikari/events/test_voice_events.py b/tests/hikari/events/test_voice_events.py index f8ff879e91..94b98840c2 100644 --- a/tests/hikari/events/test_voice_events.py +++ b/tests/hikari/events/test_voice_events.py @@ -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"