mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-31 13:32:57 +00:00 
			
		
		
		
	Add discovery_splash and community field to Guild.edit
This commit is contained in:
		| @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. | |||||||
|  |  | ||||||
| import copy | import copy | ||||||
| from collections import namedtuple | from collections import namedtuple | ||||||
| from typing import List, TYPE_CHECKING | from typing import List, Optional, TYPE_CHECKING, overload | ||||||
|  |  | ||||||
| from . import utils, abc | from . import utils, abc | ||||||
| from .role import Role | from .role import Role | ||||||
| @@ -991,8 +991,39 @@ class Guild(Hashable): | |||||||
|  |  | ||||||
|         await self._state.http.delete_guild(self.id) |         await self._state.http.delete_guild(self.id) | ||||||
|  |  | ||||||
|  |     @overload | ||||||
|  |     async def edit( | ||||||
|  |         self, | ||||||
|  |         *, | ||||||
|  |         reason: Optional[str] = ..., | ||||||
|  |         name: str = ..., | ||||||
|  |         description: Optional[str] = ..., | ||||||
|  |         icon: Optional[bytes] = ..., | ||||||
|  |         banner: Optional[bytes] = ..., | ||||||
|  |         splash: Optional[bytes] = ..., | ||||||
|  |         discovery_splash: Optional[bytes] = ..., | ||||||
|  |         community: bool = ..., | ||||||
|  |         region: Optional[VoiceRegion] = ..., | ||||||
|  |         afk_channel: Optional[VoiceChannel] = ..., | ||||||
|  |         afk_timeout: int = ..., | ||||||
|  |         default_notifications: NotificationLevel = ..., | ||||||
|  |         verification_level: VerificationLevel = ..., | ||||||
|  |         explicit_content_filter: ContentFilter = ..., | ||||||
|  |         vanity_code: str = ..., | ||||||
|  |         system_channel: Optional[TextChannel] = ..., | ||||||
|  |         system_channel_flags: SystemChannelFlags = ..., | ||||||
|  |         preferred_locale: str = ..., | ||||||
|  |         rules_channel: Optional[TextChannel] = ..., | ||||||
|  |         public_updates_channel: Optional[TextChannel] = ..., | ||||||
|  |     ) -> None: | ||||||
|  |         ... | ||||||
|  |  | ||||||
|  |     @overload | ||||||
|  |     async def edit(self) -> None: | ||||||
|  |         ... | ||||||
|  |  | ||||||
|     async def edit(self, *, reason=None, **fields): |     async def edit(self, *, reason=None, **fields): | ||||||
|         """|coro| |         r"""|coro| | ||||||
|  |  | ||||||
|         Edits the guild. |         Edits the guild. | ||||||
|  |  | ||||||
| @@ -1002,25 +1033,37 @@ class Guild(Hashable): | |||||||
|         .. versionchanged:: 1.4 |         .. versionchanged:: 1.4 | ||||||
|             The `rules_channel` and `public_updates_channel` keyword-only parameters were added. |             The `rules_channel` and `public_updates_channel` keyword-only parameters were added. | ||||||
|  |  | ||||||
|  |         .. versionchanged:: 2.0 | ||||||
|  |             The `discovery_splash` and `community` keyword-only parameters were added. | ||||||
|  |  | ||||||
|         Parameters |         Parameters | ||||||
|         ---------- |         ---------- | ||||||
|         name: :class:`str` |         name: :class:`str` | ||||||
|             The new name of the guild. |             The new name of the guild. | ||||||
|         description: :class:`str` |         description: Optional[:class:`str`] | ||||||
|             The new description of the guild. This is only available to guilds that |             The new description of the guild. Could be ``None`` for no description. | ||||||
|             contain ``PUBLIC`` in :attr:`Guild.features`. |              This is only available to guilds that contain ``PUBLIC`` in :attr:`Guild.features`. | ||||||
|         icon: :class:`bytes` |         icon: :class:`bytes` | ||||||
|             A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG is supported. |             A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG is supported. | ||||||
|             GIF is only available to guilds that contain ``ANIMATED_ICON`` in :attr:`Guild.features`. |             GIF is only available to guilds that contain ``ANIMATED_ICON`` in :attr:`Guild.features`. | ||||||
|             Could be ``None`` to denote removal of the icon. |             Could be ``None`` to denote removal of the icon. | ||||||
|         banner: :class:`bytes` |         banner: :class:`bytes` | ||||||
|             A :term:`py:bytes-like object` representing the banner. |             A :term:`py:bytes-like object` representing the banner. | ||||||
|             Could be ``None`` to denote removal of the banner. |             Could be ``None`` to denote removal of the banner. This is only available to guilds that contain | ||||||
|  |             ``BANNER`` in :attr:`Guild.features`. | ||||||
|         splash: :class:`bytes` |         splash: :class:`bytes` | ||||||
|             A :term:`py:bytes-like object` representing the invite splash. |             A :term:`py:bytes-like object` representing the invite splash. | ||||||
|             Only PNG/JPEG supported. Could be ``None`` to denote removing the |             Only PNG/JPEG supported. Could be ``None`` to denote removing the | ||||||
|             splash. This is only available to guilds that contain ``INVITE_SPLASH`` |             splash. This is only available to guilds that contain ``INVITE_SPLASH`` | ||||||
|             in :attr:`Guild.features`. |             in :attr:`Guild.features`. | ||||||
|  |         discovery_splash: :class:`bytes` | ||||||
|  |             A :term:`py:bytes-like object` representing the discovery splash. | ||||||
|  |             Only PNG/JPEG supported. Could be ``None`` to denote removing the | ||||||
|  |             splash. This is only available to guilds that contain ``DISCOVERABLE`` | ||||||
|  |             in :attr:`Guild.features`. | ||||||
|  |         community: :class:`bool` | ||||||
|  |             Whether the guild should be a Community guild. If set to ``True``\, both ``rules_channel`` | ||||||
|  |             and ``public_updates_channel`` parameters are required. | ||||||
|         region: :class:`VoiceRegion` |         region: :class:`VoiceRegion` | ||||||
|             The new region for the guild's voice communication. |             The new region for the guild's voice communication. | ||||||
|         afk_channel: Optional[:class:`VoiceChannel`] |         afk_channel: Optional[:class:`VoiceChannel`] | ||||||
| @@ -1106,6 +1149,16 @@ class Guild(Hashable): | |||||||
|             else: |             else: | ||||||
|                 splash = None |                 splash = None | ||||||
|  |  | ||||||
|  |         try: | ||||||
|  |             discovery_splash_bytes = fields['discovery_splash'] | ||||||
|  |         except KeyError: | ||||||
|  |             pass | ||||||
|  |         else: | ||||||
|  |             if discovery_splash_bytes is not None: | ||||||
|  |                 fields['discovery_splash'] = utils._bytes_to_base64_data(discovery_splash_bytes) | ||||||
|  |             else: | ||||||
|  |                 fields['discovery_splash'] = None | ||||||
|  |  | ||||||
|         fields['icon'] = icon |         fields['icon'] = icon | ||||||
|         fields['banner'] = banner |         fields['banner'] = banner | ||||||
|         fields['splash'] = splash |         fields['splash'] = splash | ||||||
| @@ -1181,6 +1234,21 @@ class Guild(Hashable): | |||||||
|                 fields['public_updates_channel_id'] = public_updates_channel |                 fields['public_updates_channel_id'] = public_updates_channel | ||||||
|             else: |             else: | ||||||
|                 fields['public_updates_channel_id'] = public_updates_channel.id |                 fields['public_updates_channel_id'] = public_updates_channel.id | ||||||
|  |  | ||||||
|  |         try: | ||||||
|  |             community = fields.pop('community') | ||||||
|  |         except KeyError: | ||||||
|  |             pass | ||||||
|  |         else: | ||||||
|  |             features = [] | ||||||
|  |             if community: | ||||||
|  |                 if 'rules_channel_id' in fields and 'public_updates_channel_id' in fields: | ||||||
|  |                     features.append('COMMUNITY') | ||||||
|  |                 else: | ||||||
|  |                     raise InvalidArgument('community field requires both rules_channel and public_updates_channel fields to be provided') | ||||||
|  |  | ||||||
|  |             fields['features'] = features | ||||||
|  |  | ||||||
|         await http.edit_guild(self.id, reason=reason, **fields) |         await http.edit_guild(self.id, reason=reason, **fields) | ||||||
|  |  | ||||||
|     async def fetch_channels(self): |     async def fetch_channels(self): | ||||||
|   | |||||||
| @@ -785,6 +785,8 @@ class HTTPClient: | |||||||
|             'owner_id', |             'owner_id', | ||||||
|             'afk_channel_id', |             'afk_channel_id', | ||||||
|             'splash', |             'splash', | ||||||
|  |             'discovery_splash', | ||||||
|  |             'features', | ||||||
|             'verification_level', |             'verification_level', | ||||||
|             'system_channel_id', |             'system_channel_id', | ||||||
|             'default_message_notifications', |             'default_message_notifications', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user