aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
Diffstat (limited to 'discord')
-rw-r--r--discord/guild.py80
-rw-r--r--discord/http.py2
2 files changed, 76 insertions, 6 deletions
diff --git a/discord/guild.py b/discord/guild.py
index dac1c6fa..6c0b0901 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
import copy
from collections import namedtuple
-from typing import List, TYPE_CHECKING
+from typing import List, Optional, TYPE_CHECKING, overload
from . import utils, abc
from .role import Role
@@ -991,8 +991,39 @@ class Guild(Hashable):
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):
- """|coro|
+ r"""|coro|
Edits the guild.
@@ -1002,25 +1033,37 @@ class Guild(Hashable):
.. versionchanged:: 1.4
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
----------
name: :class:`str`
The new name of the guild.
- description: :class:`str`
- The new description of the guild. This is only available to guilds that
- contain ``PUBLIC`` in :attr:`Guild.features`.
+ description: Optional[:class:`str`]
+ The new description of the guild. Could be ``None`` for no description.
+ This is only available to guilds that contain ``PUBLIC`` in :attr:`Guild.features`.
icon: :class:`bytes`
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`.
Could be ``None`` to denote removal of the icon.
banner: :class:`bytes`
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`
A :term:`py:bytes-like object` representing the invite splash.
Only PNG/JPEG supported. Could be ``None`` to denote removing the
splash. This is only available to guilds that contain ``INVITE_SPLASH``
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`
The new region for the guild's voice communication.
afk_channel: Optional[:class:`VoiceChannel`]
@@ -1106,6 +1149,16 @@ class Guild(Hashable):
else:
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['banner'] = banner
fields['splash'] = splash
@@ -1181,6 +1234,21 @@ class Guild(Hashable):
fields['public_updates_channel_id'] = public_updates_channel
else:
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)
async def fetch_channels(self):
diff --git a/discord/http.py b/discord/http.py
index 0eb48124..dcd6131e 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -785,6 +785,8 @@ class HTTPClient:
'owner_id',
'afk_channel_id',
'splash',
+ 'discovery_splash',
+ 'features',
'verification_level',
'system_channel_id',
'default_message_notifications',