mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Add support for default notification level in audit logs and Guild.edit
This commit is contained in:
parent
c30b016bb5
commit
8b18fa307b
@ -33,6 +33,9 @@ from .invite import Invite
|
||||
def _transform_verification_level(entry, data):
|
||||
return enums.try_enum(enums.VerificationLevel, data)
|
||||
|
||||
def _transform_default_notifications(entry, data):
|
||||
return enums.try_enum(enums.NotificationLevel, data)
|
||||
|
||||
def _transform_explicit_content_filter(entry, data):
|
||||
return enums.try_enum(enums.ContentFilter, data)
|
||||
|
||||
@ -94,24 +97,25 @@ class AuditLogDiff:
|
||||
|
||||
class AuditLogChanges:
|
||||
TRANSFORMERS = {
|
||||
'verification_level': (None, _transform_verification_level),
|
||||
'explicit_content_filter': (None, _transform_explicit_content_filter),
|
||||
'allow': (None, _transform_permissions),
|
||||
'deny': (None, _transform_permissions),
|
||||
'permissions': (None, _transform_permissions),
|
||||
'id': (None, _transform_snowflake),
|
||||
'color': ('colour', _transform_color),
|
||||
'owner_id': ('owner', _transform_owner_id),
|
||||
'inviter_id': ('inviter', _transform_inviter_id),
|
||||
'channel_id': ('channel', _transform_channel),
|
||||
'afk_channel_id': ('afk_channel', _transform_channel),
|
||||
'system_channel_id': ('system_channel', _transform_channel),
|
||||
'widget_channel_id': ('widget_channel', _transform_channel),
|
||||
'permission_overwrites': ('overwrites', _transform_overwrites),
|
||||
'splash_hash': ('splash', None),
|
||||
'icon_hash': ('icon', None),
|
||||
'avatar_hash': ('avatar', None),
|
||||
'rate_limit_per_user': ('slowmode_delay', None),
|
||||
'verification_level': (None, _transform_verification_level),
|
||||
'explicit_content_filter': (None, _transform_explicit_content_filter),
|
||||
'allow': (None, _transform_permissions),
|
||||
'deny': (None, _transform_permissions),
|
||||
'permissions': (None, _transform_permissions),
|
||||
'id': (None, _transform_snowflake),
|
||||
'color': ('colour', _transform_color),
|
||||
'owner_id': ('owner', _transform_owner_id),
|
||||
'inviter_id': ('inviter', _transform_inviter_id),
|
||||
'channel_id': ('channel', _transform_channel),
|
||||
'afk_channel_id': ('afk_channel', _transform_channel),
|
||||
'system_channel_id': ('system_channel', _transform_channel),
|
||||
'widget_channel_id': ('widget_channel', _transform_channel),
|
||||
'permission_overwrites': ('overwrites', _transform_overwrites),
|
||||
'splash_hash': ('splash', None),
|
||||
'icon_hash': ('icon', None),
|
||||
'avatar_hash': ('avatar', None),
|
||||
'rate_limit_per_user': ('slowmode_delay', None),
|
||||
'default_message_notifications': ('default_notifications', _transform_default_notifications),
|
||||
}
|
||||
|
||||
def __init__(self, entry, data):
|
||||
|
@ -123,7 +123,7 @@ class RelationshipType(Enum):
|
||||
incoming_request = 3
|
||||
outgoing_request = 4
|
||||
|
||||
class NotificationLevel(Enum):
|
||||
class NotificationLevel(IntEnum):
|
||||
all_messages = 0
|
||||
only_mentions = 1
|
||||
|
||||
|
@ -748,6 +748,8 @@ class Guild(Hashable):
|
||||
be owner of the guild to do this.
|
||||
verification_level: :class:`VerificationLevel`
|
||||
The new verification level for the guild.
|
||||
default_notifications: :class:`NotificationLevel`
|
||||
The new default notification level for the guild.
|
||||
vanity_code: str
|
||||
The new vanity code for the guild.
|
||||
system_channel: Optional[:class:`TextChannel`]
|
||||
@ -798,6 +800,13 @@ class Guild(Hashable):
|
||||
fields['icon'] = icon
|
||||
fields['splash'] = splash
|
||||
|
||||
try:
|
||||
default_message_notifications = int(fields.pop('default_notifications'))
|
||||
except (TypeError, KeyError):
|
||||
pass
|
||||
else:
|
||||
fields['default_message_notifications'] = default_message_notifications
|
||||
|
||||
try:
|
||||
afk_channel = fields.pop('afk_channel')
|
||||
except KeyError:
|
||||
|
@ -565,7 +565,7 @@ class HTTPClient:
|
||||
def edit_guild(self, guild_id, *, reason=None, **fields):
|
||||
valid_keys = ('name', 'region', 'icon', 'afk_timeout', 'owner_id',
|
||||
'afk_channel_id', 'splash', 'verification_level',
|
||||
'system_channel_id')
|
||||
'system_channel_id', 'default_message_notifications')
|
||||
|
||||
payload = {
|
||||
k: v for k, v in fields.items() if k in valid_keys
|
||||
|
@ -855,7 +855,7 @@ All enumerations are subclasses of `enum`_.
|
||||
.. class:: NotificationLevel
|
||||
|
||||
Specifies whether a :class:`Guild` has notifications on for all messages or mentions only by default.
|
||||
|
||||
|
||||
..attribute:: all_messages
|
||||
|
||||
Members receive notifications for every message regardless of them being mentioned.
|
||||
@ -1595,6 +1595,12 @@ this goal, it must make use of a couple of data classes that aid in this goal.
|
||||
|
||||
See also :attr:`Guild.verification_level`.
|
||||
|
||||
.. attribute:: default_notifications
|
||||
|
||||
:class:`NotificationLevel` – The guild's default notification level.
|
||||
|
||||
See also :attr:`Guild.default_notifications`.
|
||||
|
||||
.. attribute:: explicit_content_filter
|
||||
|
||||
:class:`ContentFilter` – The guild's content filter.
|
||||
|
Loading…
x
Reference in New Issue
Block a user