Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement text in voice #1179

Merged
merged 5 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1189.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`GuildVoiceChannel` now inherits from `TextableGuildChannel` instead of `GuildChannel`.
10 changes: 9 additions & 1 deletion hikari/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ class GuildNewsChannel(TextableGuildChannel):


@attr.define(hash=True, kw_only=True, weakref_slot=False)
class GuildVoiceChannel(GuildChannel):
class GuildVoiceChannel(TextableGuildChannel):
hypergonial marked this conversation as resolved.
Show resolved Hide resolved
"""Represents a voice channel."""

bitrate: int = attr.field(eq=False, hash=False, repr=True)
Expand All @@ -1311,6 +1311,14 @@ class GuildVoiceChannel(GuildChannel):
video_quality_mode: typing.Union[VideoQualityMode, int] = attr.field(eq=False, hash=False, repr=False)
"""The video quality mode for the voice channel."""

last_message_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False)
"""The ID of the last message sent in this channel.

!!! warning
This might point to an invalid or deleted message. Do not assume that
this will always be valid.
"""


@attr.define(hash=True, kw_only=True, weakref_slot=False)
class GuildStageChannel(GuildChannel):
Expand Down
6 changes: 6 additions & 0 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,11 @@ def deserialize_guild_voice_channel(
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
# Discord seems to be only returning this after it's been initially PATCHed in for older channels.
video_quality_mode = payload.get("video_quality_mode", channel_models.VideoQualityMode.AUTO)

last_message_id: typing.Optional[snowflakes.Snowflake] = None
if (raw_last_message_id := payload.get("last_message_id")) is not None:
last_message_id = snowflakes.Snowflake(raw_last_message_id)

return channel_models.GuildVoiceChannel(
app=self._app,
id=channel_fields.id,
Expand All @@ -996,6 +1001,7 @@ def deserialize_guild_voice_channel(
bitrate=int(payload["bitrate"]),
user_limit=int(payload["user_limit"]),
video_quality_mode=channel_models.VideoQualityMode(int(video_quality_mode)),
last_message_id=last_message_id,
)

def deserialize_guild_stage_channel(
Expand Down
1 change: 1 addition & 0 deletions tests/hikari/impl/test_entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def guild_voice_channel_payload(permission_overwrite_payload):
"rtc_region": "europe",
"parent_id": "456",
"video_quality_mode": 1,
"last_message_id": 1234567890,
}


Expand Down