diff --git a/discord/enums.py b/discord/enums.py index 1d032d568..55d1c73c7 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -29,7 +29,7 @@ from enum import Enum, IntEnum __all__ = ['ChannelType', 'MessageType', 'VoiceRegion', 'VerificationLevel', 'ContentFilter', 'Status', 'DefaultAvatar', 'RelationshipType', 'AuditLogAction', 'AuditLogActionCategory', 'UserFlags', - 'ActivityType', 'HypeSquadHouse'] + 'ActivityType', 'HypeSquadHouse', 'NotificationLevel'] class ChannelType(Enum): text = 0 @@ -123,6 +123,10 @@ class RelationshipType(Enum): incoming_request = 3 outgoing_request = 4 +class NotificationLevel(Enum): + all_messages = 0 + only_mentions = 1 + class AuditLogActionCategory(Enum): create = 1 delete = 2 diff --git a/discord/guild.py b/discord/guild.py index add31d0fc..5d99aa068 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -35,7 +35,7 @@ from .permissions import PermissionOverwrite from .colour import Colour from .errors import InvalidArgument, ClientException from .channel import * -from .enums import VoiceRegion, Status, ChannelType, try_enum, VerificationLevel, ContentFilter +from .enums import VoiceRegion, Status, ChannelType, try_enum, VerificationLevel, ContentFilter, NotificationLevel from .mixins import Hashable from .utils import valid_icon_size from .user import User @@ -103,6 +103,8 @@ class Guild(Hashable): The guild's verification level. explicit_content_filter: :class:`ContentFilter` The guild's explicit content filter. + default_notifications: :class:`NotificationLevel` + The guild's notification settings. features: List[:class:`str`] A list of features that the guild has. They are currently as follows: @@ -121,7 +123,7 @@ class Guild(Hashable): '_default_role', '_roles', '_member_count', '_large', 'owner_id', 'mfa_level', 'emojis', 'features', 'verification_level', 'explicit_content_filter', 'splash', - '_voice_states', '_system_channel_id', ) + '_voice_states', '_system_channel_id', 'default_notifications') def __init__(self, *, data, state): self._channels = {} @@ -205,6 +207,7 @@ class Guild(Hashable): self.name = guild.get('name') self.region = try_enum(VoiceRegion, guild.get('region')) self.verification_level = try_enum(VerificationLevel, guild.get('verification_level')) + self.default_notifications = try_enum(NotificationLevel, guild.get('default_message_notifications')) self.explicit_content_filter = try_enum(ContentFilter, guild.get('explicit_content_filter', 0)) self.afk_timeout = guild.get('afk_timeout') self.icon = guild.get('icon') diff --git a/docs/api.rst b/docs/api.rst index ba7c3b348..ef6cabaf4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -852,6 +852,17 @@ All enumerations are subclasses of `enum`_. An alias for :attr:`extreme`. +.. 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. + ..attribute:: only_mentions + + Members receive notifications for messages they are mentioned in. + .. class:: ContentFilter Specifies a :class:`Guild`\'s explicit content filter, which is the machine