From 37f96e34731984aaf4b0d6ac8543556f5c526bee Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 18 Feb 2022 23:44:46 +1000 Subject: [PATCH] Add message_content intent and move to api v10 --- discord/flags.py | 28 ++++++++++++++++++++++++++++ discord/http.py | 16 ++++++---------- docs/intents.rst | 11 +++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/discord/flags.py b/discord/flags.py index fd8d9e36b..eee533769 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -514,6 +514,7 @@ class Intents(BaseFlags): self = cls.all() self.presences = False self.members = False + self.message_content = False return self @flag_value @@ -892,6 +893,33 @@ class Intents(BaseFlags): """ return 1 << 14 + @flag_value + def message_content(self): + """:class:`bool`: Whether message content, attachments, embeds and components will be available in messages + which do not meet the following criteria: + + - The message was sent by the client + - The message was sent in direct messages + - The message mentions the client + + This applies to the following events: + + - :func:`on_message` + - :func:`on_message_edit` + - :func:`on_message_delete` + - :func:`on_raw_message_edit` + + For more information go to the :ref:`message content intent documentation `. + + .. note:: + + Currently, this requires opting in explicitly via the developer portal as well. + Bots in over 100 guilds will need to apply to Discord for verification. + + .. versionadded:: 2.0 + """ + return 1 << 15 + @fill_with_flags() class MemberCacheFlags(BaseFlags): diff --git a/discord/http.py b/discord/http.py index f38ca593a..ac238e4d9 100644 --- a/discord/http.py +++ b/discord/http.py @@ -260,7 +260,7 @@ def handle_message_parameters( class Route: - BASE: ClassVar[str] = 'https://discord.com/api/v8' + BASE: ClassVar[str] = 'https://discord.com/api/v10' def __init__(self, method: str, path: str, **parameters: Any) -> None: self.path: str = path @@ -738,11 +738,7 @@ class HTTPClient: def kick(self, user_id: Snowflake, guild_id: Snowflake, reason: Optional[str] = None) -> Response[None]: r = Route('DELETE', '/guilds/{guild_id}/members/{user_id}', guild_id=guild_id, user_id=user_id) - if reason: - # thanks aiohttp - r.url = f'{r.url}?reason={_uriquote(reason)}' - - return self.request(r) + return self.request(r, reason=reason) def ban( self, @@ -1941,9 +1937,9 @@ class HTTPClient: except HTTPException as exc: raise GatewayNotFound() from exc if zlib: - value = '{0}?encoding={1}&v=9&compress=zlib-stream' + value = '{0}?encoding={1}&v=10&compress=zlib-stream' else: - value = '{0}?encoding={1}&v=9' + value = '{0}?encoding={1}&v=10' return value.format(data['url'], encoding) async def get_bot_gateway(self, *, encoding: str = 'json', zlib: bool = True) -> Tuple[int, str]: @@ -1953,9 +1949,9 @@ class HTTPClient: raise GatewayNotFound() from exc if zlib: - value = '{0}?encoding={1}&v=9&compress=zlib-stream' + value = '{0}?encoding={1}&v=10&compress=zlib-stream' else: - value = '{0}?encoding={1}&v=9' + value = '{0}?encoding={1}&v=10' return data['shards'], value.format(data['url'], encoding) def get_user(self, user_id: Snowflake) -> Response[user.User]: diff --git a/docs/intents.rst b/docs/intents.rst index a9708aafa..1c74195c8 100644 --- a/docs/intents.rst +++ b/docs/intents.rst @@ -107,6 +107,17 @@ Member Intent - Whether you want to request the guild member list through :meth:`Guild.chunk` or :meth:`Guild.fetch_members`. - Whether you want high accuracy member cache under :attr:`Guild.members`. +.. _need_message_content_intent: + +Message Content ++++++++++++++++++ + +- Whether you use :attr:`Message.content` to check message content. +- Whether you use :attr:`Message.attachments` to check message attachments. +- Whether you use :attr:`Message.embeds` to check message embeds. +- Whether you use :attr:`Message.components` to check message components. +- Whether you use the commands extension with a non-mentioning prefix. + .. _intents_member_cache: Member Cache