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

Support text in stage channels #1653

Merged
merged 5 commits into from
Jul 14, 2023
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/1653.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for text in stage channels
10 changes: 9 additions & 1 deletion hikari/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ class GuildVoiceChannel(PermissibleGuildChannel, TextableGuildChannel):


@attrs.define(hash=True, kw_only=True, weakref_slot=False)
class GuildStageChannel(PermissibleGuildChannel):
class GuildStageChannel(PermissibleGuildChannel, TextableGuildChannel):
"""Represents a stage channel."""

bitrate: int = attrs.field(eq=False, hash=False, repr=True)
Expand All @@ -1387,6 +1387,14 @@ class GuildStageChannel(PermissibleGuildChannel):
If this is `0`, then assume no limit.
"""

last_message_id: typing.Optional[snowflakes.Snowflake] = attrs.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.
"""


@typing.final
class ForumSortOrderType(int, enums.Enum):
Expand Down
2 changes: 2 additions & 0 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ def deserialize_guild_stage_channel(
snowflakes.Snowflake(overwrite["id"]): self.deserialize_permission_overwrite(overwrite)
for overwrite in payload["permission_overwrites"]
}
last_message_id = snowflakes.Snowflake(payload["last_message_id"]) if "last_message_id" in payload else None
return channel_models.GuildStageChannel(
app=self._app,
id=channel_fields.id,
Expand All @@ -1186,6 +1187,7 @@ def deserialize_guild_stage_channel(
bitrate=int(payload["bitrate"]),
user_limit=int(payload["user_limit"]),
position=int(payload["position"]),
last_message_id=last_message_id,
)

def deserialize_guild_forum_channel(
Expand Down
5 changes: 5 additions & 0 deletions tests/hikari/impl/test_entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,7 @@ def guild_stage_channel_payload(self, permission_overwrite_payload):
"user_limit": 3,
"rtc_region": "euoo",
"parent_id": "543",
"last_message_id": "1000101",
}

def test_deserialize_guild_stage_channel(
Expand All @@ -2018,6 +2019,7 @@ def test_deserialize_guild_stage_channel(
assert voice_channel.region == "euoo"
assert voice_channel.bitrate == 64000
assert voice_channel.user_limit == 3
assert voice_channel.last_message_id == 1000101
assert isinstance(voice_channel, channel_models.GuildStageChannel)

def test_deserialize_guild_stage_channel_with_null_fields(self, entity_factory_impl):
Expand All @@ -2034,10 +2036,12 @@ def test_deserialize_guild_stage_channel_with_null_fields(self, entity_factory_i
"user_limit": 3,
"rtc_region": None,
"type": 6,
"last_message_id": None,
novanai marked this conversation as resolved.
Show resolved Hide resolved
}
)
assert voice_channel.parent_id is None
assert voice_channel.region is None
assert voice_channel.last_message_id is None

def test_deserialize_guild_stage_channel_with_unset_fields(self, entity_factory_impl):
voice_channel = entity_factory_impl.deserialize_guild_stage_channel(
Expand All @@ -2055,6 +2059,7 @@ def test_deserialize_guild_stage_channel_with_unset_fields(self, entity_factory_
)
assert voice_channel.parent_id is None
assert voice_channel.is_nsfw is False
assert voice_channel.last_message_id is None

@pytest.fixture()
def guild_forum_channel_payload(self, permission_overwrite_payload):
Expand Down