diff --git a/changes/1474.bugfix.md b/changes/1474.bugfix.md new file mode 100644 index 0000000000..26f99e7db1 --- /dev/null +++ b/changes/1474.bugfix.md @@ -0,0 +1 @@ +Add missing fields to `GuildChannel.edit`. diff --git a/changes/1474.feature.md b/changes/1474.feature.md new file mode 100644 index 0000000000..fc150802e0 --- /dev/null +++ b/changes/1474.feature.md @@ -0,0 +1 @@ +Update `RESTClient.edit_channnel` to support setting `applied_tags` on forum threads. diff --git a/hikari/api/rest.py b/hikari/api/rest.py index e626ce122c..d26413e412 100644 --- a/hikari/api/rest.py +++ b/hikari/api/rest.py @@ -227,6 +227,7 @@ async def edit_channel( locked: undefined.UndefinedOr[bool] = undefined.UNDEFINED, invitable: undefined.UndefinedOr[bool] = undefined.UNDEFINED, auto_archive_duration: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, + applied_tags: undefined.UndefinedOr[typing.Sequence[channels_.ForumTag]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.PartialChannel: """Edit a channel. @@ -242,7 +243,9 @@ async def edit_channel( name : hikari.undefined.UndefinedOr[str] If provided, the new name for the channel. flags : hikari.undefined.UndefinedOr[hikari.channels.ChannelFlag] - If provided, the new flags for the channel + If provided, the new channel flags to use for the channel. This can + only be used on a forum channel to apply `REQUIRE_TAG`, or + on a forum thread to apply `PINNED`. position : hikari.undefined.UndefinedOr[int] If provided, the new position for the channel. topic : hikari.undefined.UndefinedOr[str] @@ -291,21 +294,25 @@ async def edit_channel( This only applies to forum channels. archived : hikari.undefined.UndefinedOr[bool] - If provided, whether to archive or unarchive this thread channel. + If provided, the new archived state for the thread. This only + applies to threads. locked : hikari.undefined.UndefinedOr[bool] - If provided, whether to lock or unlock this thread channel. + If provided, the new locked state for the thread. This only applies + to threads. If it's locked then only people with `MANAGE_THREADS` can unarchive it. invitable : undefined.UndefinedOr[bool] - If provided, whether non-moderators should be able to add other non-moderators to the thread. - - This only applies to private threads. + If provided, the new setting for whether non-moderators can invite + new members to a private thread. This only applies to threads. auto_archive_duration : hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish] - If provided, how long the thread should remain inactive until it's archived. - - This should be either 60, 1440, 4320 or 10080 seconds and, as of - writing, ignores the parent channel's set default_auto_archive_duration - when passed as `hikari.undefined.UNDEFINED`. + If provided, the new auto archive duration for this thread. This + only applies to threads. + + This should be either 60, 1440, 4320 or 10080 seconds, as of + writing. + applied_tags : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.ForumTag]] + If provided, the new tags to apply to the thread. This only applies + to threads in a forum channel. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. diff --git a/hikari/channels.py b/hikari/channels.py index 3bd8a124ea..d85764aaae 100644 --- a/hikari/channels.py +++ b/hikari/channels.py @@ -1058,6 +1058,14 @@ async def edit( permission_overwrites: undefined.UndefinedOr[typing.Sequence[PermissionOverwrite]] = undefined.UNDEFINED, parent_category: undefined.UndefinedOr[snowflakes.SnowflakeishOr[GuildCategory]] = undefined.UNDEFINED, default_auto_archive_duration: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, + # Forum & Thread-only fields + flags: undefined.UndefinedOr[ChannelFlag] = undefined.UNDEFINED, + # Thread-only fields + archived: undefined.UndefinedOr[bool] = undefined.UNDEFINED, + auto_archive_duration: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, + locked: undefined.UndefinedOr[bool] = undefined.UNDEFINED, + invitable: undefined.UndefinedOr[bool] = undefined.UNDEFINED, + applied_tags: undefined.UndefinedOr[typing.Sequence[ForumTag]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> PartialChannel: """Edit the text channel. @@ -1093,8 +1101,32 @@ async def edit( If provided, the auto archive duration Discord's end user client should default to when creating threads in this channel. - This should be either 60, 1440, 4320 or 10080 seconds and, as of + This should be either 60, 1440, 4320 or 10080 seconds, as of writing. + flags : hikari.undefined.UndefinedOr[ChannelFlag] + If provided, the new channel flags to use for the channel. This can + only be used on a forum channel to apply ChannelFlag.REQUIRE_TAG, or + on a forum thread to apply ChannelFlag.PINNED. + archived : hikari.undefined.UndefinedOr[bool] + If provided, the new archived state for the thread. This only + applies to threads. + auto_archive_duration : hikari.undefined.UndefinedOr[time.Intervalish] + If provided, the new auto archive duration for this thread. This + only applies to threads. + + This should be either 60, 1440, 4320 or 10080 seconds, as of + writing. + locked : hikari.undefined.UndefinedOr[bool] + If provided, the new locked state for the thread. This only applies + to threads. + + If it's locked then only people with `MANAGE_THREADS` can unarchive it. + invitable : hikari.undefined.UndefinedOr[bool] + If provided, the new setting for whether non-moderators can invite + new members to a private thread. This only applies to threads. + applied_tags : hikari.undefined.UndefinedOr[typing.Sequence[ForumTag]] + If provided, the new tags to apply to the thread. This only applies + to threads in a forum channel. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. @@ -1142,6 +1174,12 @@ async def edit( permission_overwrites=permission_overwrites, parent_category=parent_category, default_auto_archive_duration=default_auto_archive_duration, + flags=flags, + archived=archived, + auto_archive_duration=auto_archive_duration, + locked=locked, + invitable=invitable, + applied_tags=applied_tags, reason=reason, ) diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py index 56c04d8a0e..a7a421ac45 100644 --- a/hikari/impl/rest.py +++ b/hikari/impl/rest.py @@ -1003,6 +1003,7 @@ async def edit_channel( locked: undefined.UndefinedOr[bool] = undefined.UNDEFINED, invitable: undefined.UndefinedOr[bool] = undefined.UNDEFINED, auto_archive_duration: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, + applied_tags: undefined.UndefinedOr[typing.Sequence[channels_.ForumTag]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.PartialChannel: if isinstance(auto_archive_duration, datetime.timedelta): @@ -1054,6 +1055,7 @@ async def edit_channel( body.put("auto_archive_duration", auto_archive_duration, conversion=time.timespan_to_int) body.put("locked", locked) body.put("invitable", invitable) + body.put_array("applied_tags", applied_tags, conversion=self._entity_factory.serialize_forum_tag) response = await self._request(route, json=body, reason=reason) assert isinstance(response, dict) diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py index 22bc5535f7..83160244a0 100644 --- a/tests/hikari/impl/test_rest.py +++ b/tests/hikari/impl/test_rest.py @@ -2202,6 +2202,8 @@ async def test_edit_channel( "locked": False, "invitable": True, "auto_archive_duration": 12322, + "flags": 12, + "applied_tags": [{"id": 0, "name": "testing", "moderated": True, "emoji_id": None, "emoji_name": None}], } result = await rest_client.edit_channel( @@ -2235,6 +2237,8 @@ async def test_edit_channel( locked=False, invitable=True, auto_archive_duration=auto_archive_duration, + flags=12, + applied_tags=[channels.ForumTag(name="testing", moderated=True)], ) assert result == mock_object diff --git a/tests/hikari/test_channels.py b/tests/hikari/test_channels.py index 0c0bbfd270..084f81d92f 100644 --- a/tests/hikari/test_channels.py +++ b/tests/hikari/test_channels.py @@ -364,6 +364,12 @@ async def test_edit(self, model): region="us-west", parent_category=341123123123, permission_overwrites={123: "123"}, + flags=12, + archived=True, + auto_archive_duration=1234, + locked=True, + invitable=True, + applied_tags=[12345, 54321], ) assert result is model.app.rest.edit_channel.return_value @@ -381,6 +387,12 @@ async def test_edit(self, model): permission_overwrites={123: "123"}, parent_category=341123123123, default_auto_archive_duration=123312, + flags=12, + archived=True, + auto_archive_duration=1234, + locked=True, + invitable=True, + applied_tags=[12345, 54321], reason="left right", )