Skip to content

Commit

Permalink
Add missing video_quality_mode field to GuildStageChannel
Browse files Browse the repository at this point in the history
Also fix typos attrsibutes -> attributes
  • Loading branch information
beagold committed Apr 25, 2024
1 parent b63440e commit 2ce65ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
5 changes: 4 additions & 1 deletion hikari/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ class GuildVoiceChannel(PermissibleGuildChannel, TextableGuildChannel):
"""

video_quality_mode: typing.Union[VideoQualityMode, int] = attrs.field(eq=False, hash=False, repr=False)
"""The video quality mode for the voice channel."""
"""The video quality mode for this channel."""

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.
Expand Down Expand Up @@ -1390,6 +1390,9 @@ class GuildStageChannel(PermissibleGuildChannel, TextableGuildChannel):
If this is `0`, then assume no limit.
"""

video_quality_mode: typing.Union[VideoQualityMode, int] = attrs.field(eq=False, hash=False, repr=False)
"""The video quality mode for this channel."""

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.
Expand Down
45 changes: 24 additions & 21 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ def deserialize_group_dm(self, payload: data_binding.JSONObject) -> channel_mode
recipients=recipients,
)

def _set_guild_channel_attrsibutes(
def _set_guild_channel_attributes(
self, payload: data_binding.JSONObject, *, guild_id: undefined.UndefinedOr[snowflakes.Snowflake]
) -> _GuildChannelFields:
if guild_id is undefined.UNDEFINED:
Expand All @@ -1030,7 +1030,7 @@ def deserialize_guild_category(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildCategory:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
permission_overwrites = {
snowflakes.Snowflake(overwrite["id"]): self.deserialize_permission_overwrite(overwrite)
for overwrite in payload["permission_overwrites"]
Expand All @@ -1053,7 +1053,7 @@ def deserialize_guild_text_channel(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildTextChannel:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
# As of present this isn't included in the payloads of old channels where it hasn't been explicitly set.
# In this case it's 1440 minutes.
default_auto_archive_duration = datetime.timedelta(minutes=payload.get("default_auto_archive_duration", 1440))
Expand Down Expand Up @@ -1096,7 +1096,7 @@ def deserialize_guild_news_channel(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildNewsChannel:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
# As of present this isn't included in the payloads of old channels where it hasn't been explicitly set.
# In this case it's 1440 minutes.
default_auto_archive_duration = datetime.timedelta(minutes=payload.get("default_auto_archive_duration", 1440))
Expand Down Expand Up @@ -1135,11 +1135,7 @@ def deserialize_guild_voice_channel(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildVoiceChannel:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
permission_overwrites = {
snowflakes.Snowflake(overwrite["id"]): self.deserialize_permission_overwrite(overwrite)
for overwrite in payload["permission_overwrites"]
}
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)

Expand All @@ -1153,7 +1149,10 @@ def deserialize_guild_voice_channel(
name=channel_fields.name,
type=channel_fields.type,
guild_id=channel_fields.guild_id,
permission_overwrites=permission_overwrites,
permission_overwrites={
snowflakes.Snowflake(overwrite["id"]): self.deserialize_permission_overwrite(overwrite)
for overwrite in payload["permission_overwrites"]
},
is_nsfw=payload.get("nsfw", False),
parent_id=channel_fields.parent_id,
# There seems to be an edge case where rtc_region won't be included in gateway events (e.g. GUILD_CREATE)
Expand All @@ -1172,7 +1171,10 @@ def deserialize_guild_stage_channel(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildStageChannel:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
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:
Expand All @@ -1193,6 +1195,7 @@ def deserialize_guild_stage_channel(
region=payload["rtc_region"],
bitrate=int(payload["bitrate"]),
user_limit=int(payload["user_limit"]),
video_quality_mode=channel_models.VideoQualityMode(int(video_quality_mode)),
position=int(payload["position"]),
last_message_id=last_message_id,
)
Expand All @@ -1203,7 +1206,7 @@ def deserialize_guild_forum_channel(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildForumChannel:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)

# As of present this isn't included in the payloads of old channels where it hasn't been explicitly set.
# In this case it's 1440 minutes.
Expand Down Expand Up @@ -1322,7 +1325,7 @@ def deserialize_guild_news_thread(
member: undefined.UndefinedNoneOr[channel_models.ThreadMember] = undefined.UNDEFINED,
user_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildNewsThread:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
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)
Expand Down Expand Up @@ -1370,7 +1373,7 @@ def deserialize_guild_public_thread(
member: undefined.UndefinedNoneOr[channel_models.ThreadMember] = undefined.UNDEFINED,
user_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildPublicThread:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
flags = (
channel_models.ChannelFlag(raw_flags)
if (raw_flags := payload.get("flags"))
Expand Down Expand Up @@ -1426,7 +1429,7 @@ def deserialize_guild_private_thread(
member: undefined.UndefinedNoneOr[channel_models.ThreadMember] = undefined.UNDEFINED,
user_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> channel_models.GuildPrivateThread:
channel_fields = self._set_guild_channel_attrsibutes(payload, guild_id=guild_id)
channel_fields = self._set_guild_channel_attributes(payload, guild_id=guild_id)
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)
Expand Down Expand Up @@ -1883,7 +1886,7 @@ def deserialize_role(
)

@staticmethod
def _set_partial_integration_attrsibutes(payload: data_binding.JSONObject) -> _IntegrationFields:
def _set_partial_integration_attributes(payload: data_binding.JSONObject) -> _IntegrationFields:
account_payload = payload["account"]
account = guild_models.IntegrationAccount(id=account_payload["id"], name=account_payload["name"])
return _IntegrationFields(
Expand All @@ -1894,7 +1897,7 @@ def _set_partial_integration_attrsibutes(payload: data_binding.JSONObject) -> _I
)

def deserialize_partial_integration(self, payload: data_binding.JSONObject) -> guild_models.PartialIntegration:
integration_fields = self._set_partial_integration_attrsibutes(payload)
integration_fields = self._set_partial_integration_attributes(payload)
return guild_models.PartialIntegration(
id=integration_fields.id,
name=integration_fields.name,
Expand All @@ -1908,7 +1911,7 @@ def deserialize_integration(
*,
guild_id: undefined.UndefinedOr[snowflakes.Snowflake] = undefined.UNDEFINED,
) -> guild_models.Integration:
integration_fields = self._set_partial_integration_attrsibutes(payload)
integration_fields = self._set_partial_integration_attributes(payload)

role_id: typing.Optional[snowflakes.Snowflake] = None
if (raw_role_id := payload.get("role_id")) is not None:
Expand Down Expand Up @@ -2066,7 +2069,7 @@ def deserialize_gateway_guild(
def deserialize_vanity_url(self, payload: data_binding.JSONObject) -> invite_models.VanityURL:
return invite_models.VanityURL(app=self._app, code=payload["code"], uses=int(payload["uses"]))

def _set_invite_attrsibutes(self, payload: data_binding.JSONObject) -> _InviteFields:
def _set_invite_attributes(self, payload: data_binding.JSONObject) -> _InviteFields:
guild: typing.Optional[invite_models.InviteGuild] = None
guild_id: typing.Optional[snowflakes.Snowflake] = None
if "guild" in payload:
Expand Down Expand Up @@ -2131,7 +2134,7 @@ def _set_invite_attrsibutes(self, payload: data_binding.JSONObject) -> _InviteFi
)

def deserialize_invite(self, payload: data_binding.JSONObject) -> invite_models.Invite:
invite_fields = self._set_invite_attrsibutes(payload)
invite_fields = self._set_invite_attributes(payload)

expires_at: typing.Optional[datetime.datetime] = None
if raw_expires_at := payload.get("expires_at"):
Expand All @@ -2154,7 +2157,7 @@ def deserialize_invite(self, payload: data_binding.JSONObject) -> invite_models.
)

def deserialize_invite_with_metadata(self, payload: data_binding.JSONObject) -> invite_models.InviteWithMetadata:
invite_fields = self._set_invite_attrsibutes(payload)
invite_fields = self._set_invite_attributes(payload)
created_at = time.iso8601_datetime_string_to_datetime(payload["created_at"])
max_uses = int(payload["max_uses"])

Expand Down

0 comments on commit 2ce65ab

Please sign in to comment.