From c4def4d2a026f82a22ad6cf643cc5de93859e24a Mon Sep 17 00:00:00 2001 From: StockerMC <44980366+StockerMC@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:47:55 -0500 Subject: [PATCH] Bump api and gateway version to v10 and add Intents.message_content --- discord/flags.py | 34 ++++++++++++++++++++++++++++++++-- discord/http.py | 14 +++++++------- docs/intents.rst | 30 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/discord/flags.py b/discord/flags.py index e6456441..31b557ef 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -517,12 +517,13 @@ def none(cls) -> Self: @classmethod def default(cls) -> Self: - """A factory method that creates a :class:`Intents` with everything enabled - except :attr:`presences` and :attr:`members`. + r"""A factory method that creates a :class:`Intents` with everything enabled + except :attr:`presences`\, :attr:`members` and :attr:`message_content`. """ self = cls.all() self.presences = False self.members = False + self.message_content = False return self @flag_value @@ -901,6 +902,35 @@ def dm_typing(self): """ return 1 << 14 + @flag_value + def message_content(self): + """:class:`bool`: Whether to receive the following attributes of messages: + + - :attr:`Message.content` + - :attr:`Message.embeds` + - :attr:`Message.attachments` + - :attr:`Message.components` + + This means that these attributes will be set to an empty string or list depending + on the type of the attribute. + + The bot will still receive these attributes if: + + - The message was sent by the bot + - The message was sent in the bot's DMs + - The message mentions the bot + + These restrictions do not apply to messages received via interactions. + + 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. + """ + return 1 << 15 + @flag_value def scheduled_events(self): """:class:`bool`: Whether scheduled event related events are enabled. diff --git a/discord/http.py b/discord/http.py index bf465e4f..6e950a64 100644 --- a/discord/http.py +++ b/discord/http.py @@ -112,7 +112,7 @@ async def json_or_text(response: aiohttp.ClientResponse) -> Union[Dict[str, Any] 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 @@ -2056,10 +2056,10 @@ async def get_gateway(self, *, encoding: str = 'json', zlib: bool = True) -> str except HTTPException as exc: raise GatewayNotFound() from exc if zlib: - value = '{0}?encoding={1}&v=9&compress=zlib-stream' + value = '{0}?encoding={1}&v={2}&compress=zlib-stream' else: - value = '{0}?encoding={1}&v=9' - return value.format(data['url'], encoding) + value = '{0}?encoding={1}&v={2}' + return value.format(data['url'], encoding, 10) async def get_bot_gateway(self, *, encoding: str = 'json', zlib: bool = True) -> Tuple[int, str]: try: @@ -2068,10 +2068,10 @@ async def get_bot_gateway(self, *, encoding: str = 'json', zlib: bool = True) -> raise GatewayNotFound() from exc if zlib: - value = '{0}?encoding={1}&v=9&compress=zlib-stream' + value = '{0}?encoding={1}&v={2}&compress=zlib-stream' else: - value = '{0}?encoding={1}&v=9' - return data['shards'], value.format(data['url'], encoding) + value = '{0}?encoding={1}&v={2}' + return data['shards'], value.format(data['url'], encoding, 10) def get_user(self, user_id: Snowflake) -> Response[user.User]: return self.request(Route('GET', '/users/{user_id}', user_id=user_id)) diff --git a/docs/intents.rst b/docs/intents.rst index a9708aaf..083e70f5 100644 --- a/docs/intents.rst +++ b/docs/intents.rst @@ -109,6 +109,36 @@ Member Intent .. _intents_member_cache: +.. need_message_content_intent: + +Message Content Intent +++++++++++++++++++++++++ + +- Whether you have access to any of the following attributes: + + * :attr:`Message.content` + * :attr:`Message.embeds` + * :attr:`Message.attachments` + * :attr:`Message.components` + +This means that these attributes will be set to an empty string or list depending +on the type of the attribute. + +The bot will still receive these attributes if: + +- The message was sent by the bot +- The message was sent in the bot's DMs +- The message mentions the bot + +These restrictions do not apply to messages received via interactions. + +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. + Member Cache -------------