diff options
| author | Rapptz <[email protected]> | 2021-05-04 08:13:33 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-06-08 07:26:18 -0400 |
| commit | 4a4e73ec145e9f99c876a711ce6773197758424c (patch) | |
| tree | c3ece826d292c9c7fecbda6c4b3e06436b7fd4fc /discord/http.py | |
| parent | Allow Message.channel to be a thread (diff) | |
| download | discord.py-4a4e73ec145e9f99c876a711ce6773197758424c.tar.xz discord.py-4a4e73ec145e9f99c876a711ce6773197758424c.zip | |
Update thread typings and payloads to match documentation
Diffstat (limited to 'discord/http.py')
| -rw-r--r-- | discord/http.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/discord/http.py b/discord/http.py index 1d27996c..a40d9a5e 100644 --- a/discord/http.py +++ b/discord/http.py @@ -46,6 +46,7 @@ if TYPE_CHECKING: invite, channel, widget, + threads, ) from .types.snowflake import Snowflake @@ -741,7 +742,7 @@ class HTTPClient: name: str, auto_archive_duration: int, type: int, - ): + ) -> Response[threads.Thread]: payload = { 'name': name, 'auto_archive_duration': auto_archive_duration, @@ -760,7 +761,7 @@ class HTTPClient: name: str, auto_archive_duration: int, type: int, - ): + ) -> Response[threads.Thread]: payload = { 'name': name, 'auto_archive_duration': auto_archive_duration, @@ -775,7 +776,7 @@ class HTTPClient: def add_user_to_thread(self, channel_id: int, user_id: int): return self.request( - Route('POST', '/channels/{channel_id}/thread-members/{user_id}', channel_id=channel_id, user_id=user_id) + Route('PUT', '/channels/{channel_id}/thread-members/{user_id}', channel_id=channel_id, user_id=user_id) ) def leave_thread(self, channel_id: int): @@ -785,7 +786,9 @@ class HTTPClient: route = Route('DELETE', '/channels/{channel_id}/thread-members/{user_id}', channel_id=channel_id, user_id=user_id) return self.request(route) - def get_public_archived_threads(self, channel_id: int, before=None, limit: int = 50): + def get_public_archived_threads( + self, channel_id: int, before=None, limit: int = 50 + ) -> Response[threads.ThreadPaginationPayload]: route = Route('GET', '/channels/{channel_id}/threads/archived/public', channel_id=channel_id) params = {} @@ -794,7 +797,9 @@ class HTTPClient: params['limit'] = limit return self.request(route, params=params) - def get_private_archived_threads(self, channel_id: int, before=None, limit: int = 50): + def get_private_archived_threads( + self, channel_id: int, before=None, limit: int = 50 + ) -> Response[threads.ThreadPaginationPayload]: route = Route('GET', '/channels/{channel_id}/threads/archived/private', channel_id=channel_id) params = {} @@ -803,7 +808,9 @@ class HTTPClient: params['limit'] = limit return self.request(route, params=params) - def get_joined_private_archived_threads(self, channel_id, before=None, limit: int = 50): + def get_joined_private_archived_threads( + self, channel_id: int, before=None, limit: int = 50 + ) -> Response[threads.ThreadPaginationPayload]: route = Route('GET', '/channels/{channel_id}/users/@me/threads/archived/private', channel_id=channel_id) params = {} if before: @@ -811,6 +818,14 @@ class HTTPClient: params['limit'] = limit return self.request(route, params=params) + def get_active_threads(self, channel_id: int) -> Response[threads.ThreadPaginationPayload]: + route = Route('GET', '/channels/{channel_id}/threads/active', channel_id=channel_id) + return self.request(route) + + def get_thread_members(self, channel_id: int) -> Response[List[threads.ThreadMember]]: + route = Route('GET', '/channels/{channel_id}/thread-members', channel_id=channel_id) + return self.request(route) + # Webhook management def create_webhook(self, channel_id, *, name, avatar=None, reason=None): @@ -1456,7 +1471,9 @@ class HTTPClient: ) return self.request(r) - def get_guild_application_command_permissions(self, application_id, guild_id) -> Response[List[interactions.GuildApplicationCommandPermissions]]: + def get_guild_application_command_permissions( + self, application_id, guild_id + ) -> Response[List[interactions.GuildApplicationCommandPermissions]]: r = Route( 'GET', '/applications/{application_id}/guilds/{guild_id}/commands/permissions', @@ -1465,7 +1482,9 @@ class HTTPClient: ) return self.request(r) - def get_application_command_permissions(self, application_id, guild_id, command_id) -> Response[interactions.GuildApplicationCommandPermissions]: + def get_application_command_permissions( + self, application_id, guild_id, command_id + ) -> Response[interactions.GuildApplicationCommandPermissions]: r = Route( 'GET', '/applications/{application_id}/guilds/{guild_id}/commands/{command_id}/permissions', |