From 26eb572fdb500039bdf2bf0e4afd2215f275b4f5 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 25 Jun 2016 00:14:20 -0300 Subject: [PATCH] Added DefaultMessageNotifications --- src/Discord.Net/API/Common/Guild.cs | 2 ++ src/Discord.Net/API/DiscordAPIClient.cs | 1 - .../Entities/Guilds/DefaultMessageNotifications.cs | 10 ++++++++++ src/Discord.Net/Entities/Guilds/Guild.cs | 2 ++ src/Discord.Net/Entities/Guilds/IGuild.cs | 4 ++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/Discord.Net/Entities/Guilds/DefaultMessageNotifications.cs diff --git a/src/Discord.Net/API/Common/Guild.cs b/src/Discord.Net/API/Common/Guild.cs index 2debcf408..823405ea7 100644 --- a/src/Discord.Net/API/Common/Guild.cs +++ b/src/Discord.Net/API/Common/Guild.cs @@ -36,5 +36,7 @@ namespace Discord.API public string[] Features { get; set; } [JsonProperty("mfa_level")] public MfaLevel MfaLevel { get; set; } + [JsonProperty("default_message_notifications")] + public DefaultMessageNotifications DefaultMessageNotifications { get; set; } } } diff --git a/src/Discord.Net/API/DiscordAPIClient.cs b/src/Discord.Net/API/DiscordAPIClient.cs index e71dcccc6..41e59e12f 100644 --- a/src/Discord.Net/API/DiscordAPIClient.cs +++ b/src/Discord.Net/API/DiscordAPIClient.cs @@ -543,7 +543,6 @@ namespace Discord.API Preconditions.NotNullOrEmpty(args.Name, nameof(args.Name)); Preconditions.GreaterThan(args.OwnerId, 0, nameof(args.OwnerId)); Preconditions.NotNull(args.Region, nameof(args.Region)); - Preconditions.AtLeast(args.VerificationLevel, 0, nameof(args.VerificationLevel)); return await SendAsync("PATCH", $"guilds/{guildId}", args, options: options).ConfigureAwait(false); } diff --git a/src/Discord.Net/Entities/Guilds/DefaultMessageNotifications.cs b/src/Discord.Net/Entities/Guilds/DefaultMessageNotifications.cs new file mode 100644 index 000000000..efc107537 --- /dev/null +++ b/src/Discord.Net/Entities/Guilds/DefaultMessageNotifications.cs @@ -0,0 +1,10 @@ +namespace Discord +{ + public enum DefaultMessageNotifications + { + /// By default, only mentions will trigger notifications. + MentionsOnly = 0, + /// By default, all messages will trigger notifications. + AllMessages = 1 + } +} diff --git a/src/Discord.Net/Entities/Guilds/Guild.cs b/src/Discord.Net/Entities/Guilds/Guild.cs index 2ab46c617..d4a47f302 100644 --- a/src/Discord.Net/Entities/Guilds/Guild.cs +++ b/src/Discord.Net/Entities/Guilds/Guild.cs @@ -24,6 +24,7 @@ namespace Discord public bool IsEmbeddable { get; private set; } public VerificationLevel VerificationLevel { get; private set; } public MfaLevel MfaLevel { get; private set; } + public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } public override DiscordClient Discord { get; } public ulong? AFKChannelId { get; private set; } @@ -62,6 +63,7 @@ namespace Discord _splashId = model.Splash; VerificationLevel = model.VerificationLevel; MfaLevel = model.MfaLevel; + DefaultMessageNotifications = model.DefaultMessageNotifications; if (model.Emojis != null) { diff --git a/src/Discord.Net/Entities/Guilds/IGuild.cs b/src/Discord.Net/Entities/Guilds/IGuild.cs index 0d4d95284..7302e15f8 100644 --- a/src/Discord.Net/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net/Entities/Guilds/IGuild.cs @@ -13,6 +13,10 @@ namespace Discord int AFKTimeout { get; } /// Returns true if this guild is embeddable (e.g. widget) bool IsEmbeddable { get; } + /// Gets the default message notifications for users who haven't explicitly set their notification settings. + DefaultMessageNotifications DefaultMessageNotifications { get; } + /// Gets the level of mfa requirements a user must fulfill before being allowed to perform administrative actions in this guild. + MfaLevel MfaLevel { get; } /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. VerificationLevel VerificationLevel { get; } /// Returns the url to this guild's icon, or null if one is not set.