aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNCPlayz <[email protected]>2020-05-22 19:39:42 +0100
committerRapptz <[email protected]>2020-05-23 22:04:02 -0400
commited80ba6a5ef2d9b9bbe088d1c6034229c697d220 (patch)
tree9d65b9d9a5ffc85c27f14825beda5571e0ffdef4
parentuse `_channel_factory` instead of manual checking in `Guild._sync` (diff)
downloaddiscord.py-ed80ba6a5ef2d9b9bbe088d1c6034229c697d220.tar.xz
discord.py-ed80ba6a5ef2d9b9bbe088d1c6034229c697d220.zip
Implement some missing attributes of `Guild` (and `Guild.edit`)
-rw-r--r--discord/guild.py63
-rw-r--r--discord/http.py3
2 files changed, 59 insertions, 7 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 8470f1bb..ba9bfe5f 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -103,6 +103,10 @@ class Guild(Hashable):
The maximum amount of presences for the guild.
max_members: Optional[:class:`int`]
The maximum amount of members for the guild.
+ max_video_channel_users: Optional[:class:`int`]
+ The maximum amount of users in a video channel.
+
+ .. versionadded:: 1.4
banner: Optional[:class:`str`]
The guild's banner.
description: Optional[:class:`str`]
@@ -158,9 +162,10 @@ class Guild(Hashable):
'owner_id', 'mfa_level', 'emojis', 'features',
'verification_level', 'explicit_content_filter', 'splash',
'_voice_states', '_system_channel_id', 'default_notifications',
- 'description', 'max_presences', 'max_members', 'premium_tier',
- 'premium_subscription_count', '_system_channel_flags',
- 'preferred_locale', 'discovery_splash', '_rules_channel_id')
+ 'description', 'max_presences', 'max_members', 'max_video_channel_users',
+ 'premium_tier', 'premium_subscription_count', '_system_channel_flags',
+ 'preferred_locale', 'discovery_splash', '_rules_channel_id',
+ '_public_updates_channel_id')
_PREMIUM_GUILD_LIMITS = {
None: _GuildLimit(emoji=50, bitrate=96e3, filesize=8388608),
@@ -284,12 +289,14 @@ class Guild(Hashable):
self.description = guild.get('description')
self.max_presences = guild.get('max_presences')
self.max_members = guild.get('max_members')
+ self.max_video_channel_users = guild.get('max_video_channel_users')
self.premium_tier = guild.get('premium_tier', 0)
self.premium_subscription_count = guild.get('premium_subscription_count') or 0
self._system_channel_flags = guild.get('system_channel_flags', 0)
self.preferred_locale = guild.get('preferred_locale')
self.discovery_splash = guild.get('discovery_splash')
self._rules_channel_id = utils._get_as_snowflake(guild, 'rules_channel_id')
+ self._public_updates_channel_id = utils._get_as_snowflake(guild, 'public_updates_channel_id')
for mdata in guild.get('members', []):
member = Member(data=mdata, guild=self, state=state)
@@ -459,6 +466,19 @@ class Guild(Hashable):
return channel_id and self._channels.get(channel_id)
@property
+ def public_updates_channel(self):
+ """Optional[:class:`TextChannel`]: Return's the guild's channel where admins and
+ moderators of the guilds receive notices from Discord. This is only available to
+ guilds that contain `PUBLIC` in :attr:`Guild.features`.
+
+ If no channel is set, then this returns ``None``.
+
+ .. versionadded:: 1.4
+ """
+ channel_id = self._public_updates_channel_id
+ return channel_id and self._channels.get(channel_id)
+
+ @property
def emoji_limit(self):
""":class:`int`: The maximum number of emoji slots this guild has."""
more_emoji = 200 if 'MORE_EMOJI' in self.features else 50
@@ -947,6 +967,9 @@ class Guild(Hashable):
You must have the :attr:`~Permissions.manage_guild` permission
to edit the guild.
+ .. versionchanged:: 1.4
+ The `rules_channel` and `public_updates_channel` keyword-only parameters were added.
+
Parameters
----------
name: :class:`str`
@@ -956,7 +979,7 @@ class Guild(Hashable):
contain `PUBLIC` in :attr:`Guild.features`.
icon: :class:`bytes`
A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG supported
- and GIF for guilds with ``ANIMATED_ICON`` feature.
+ and GIF This 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.
@@ -964,8 +987,8 @@ class Guild(Hashable):
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. Only available for partnered guilds with ``INVITE_SPLASH``
- feature.
+ splash. This is only available to guilds that contain `INVITE_SPLASH`
+ in :attr:`Guild.features`.
region: :class:`VoiceRegion`
The new region for the guild's voice communication.
afk_channel: Optional[:class:`VoiceChannel`]
@@ -987,6 +1010,14 @@ class Guild(Hashable):
The new channel that is used for the system channel. Could be ``None`` for no system channel.
system_channel_flags: :class:`SystemChannelFlags`
The new system channel settings to use with the new system channel.
+ rules_channel: Optional[:class:`TextChannel`]
+ The new channel that is used for rules. This is only available to
+ guilds that contain `PUBLIC` in :attr:`Guild.features`. Could be ``None`` for no rules
+ channel.
+ public_updates_channel: Optional[:class:`TextChannel`]
+ The new channel that is used for public updates from Discord. This is only available to
+ guilds that contain `PUBLIC` in :attr:`Guild.features`. Could be ``None`` for no
+ public updates channel.
reason: Optional[:class:`str`]
The reason for editing this guild. Shows up on the audit log.
@@ -1095,6 +1126,26 @@ class Guild(Hashable):
raise InvalidArgument('system_channel_flags field must be of type SystemChannelFlags')
fields['system_channel_flags'] = system_channel_flags.value
+
+ try:
+ rules_channel = fields.pop('rules_channel')
+ except KeyError:
+ pass
+ else:
+ if rules_channel is None:
+ fields['rules_channel_id'] = rules_channel
+ else:
+ fields['rules_channel_id'] = rules_channel.id
+
+ try:
+ public_updates_channel = fields.pop('public_updates_channel')
+ except KeyError:
+ pass
+ else:
+ if rules_channel is None:
+ fields['public_updates_channel_id'] = rules_channel
+ else:
+ fields['public_updates_channel_id'] = rules_channel.id
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 d022286f..e1653ed8 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -620,7 +620,8 @@ class HTTPClient:
'afk_channel_id', 'splash', 'verification_level',
'system_channel_id', 'default_message_notifications',
'description', 'explicit_content_filter', 'banner',
- 'system_channel_flags')
+ 'system_channel_flags', 'rules_channel_id',
+ 'public_updates_channel_id')
payload = {
k: v for k, v in fields.items() if k in valid_keys