Update thread typings and payloads to match documentation

This commit is contained in:
Rapptz
2021-05-04 08:13:33 -04:00
parent ac95b8b85b
commit 4a4e73ec14
6 changed files with 77 additions and 22 deletions

View File

@@ -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',