From 5b329048dee5c940f733c8339dea2f77debae77d Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 19:27:02 -0700 Subject: [PATCH 1/4] Add ExplicitContentFilter property to Guild --- .../Entities/Guilds/ExplicitContentFilterLevel.cs | 13 +++++++++++++ src/Discord.Net.Core/Entities/Guilds/IGuild.cs | 2 ++ src/Discord.Net.Rest/API/Common/Guild.cs | 4 +++- src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs | 2 ++ .../Entities/Guilds/SocketGuild.cs | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/Discord.Net.Core/Entities/Guilds/ExplicitContentFilterLevel.cs diff --git a/src/Discord.Net.Core/Entities/Guilds/ExplicitContentFilterLevel.cs b/src/Discord.Net.Core/Entities/Guilds/ExplicitContentFilterLevel.cs new file mode 100644 index 000000000..54c0bdafe --- /dev/null +++ b/src/Discord.Net.Core/Entities/Guilds/ExplicitContentFilterLevel.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + public enum ExplicitContentFilterLevel + { + /// No messages will be scanned. + Disabled = 0, + /// Scans messages from all guild members that do not have a role. + /// Recommented option for servers that use roles for trusted membership. + MembersWithoutRoles = 1, + /// Scan messages sent by all guild members. + AllMembers = 2 + } +} diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index bbe7051cb..d64297a1e 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -19,6 +19,8 @@ namespace Discord MfaLevel MfaLevel { get; } /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. VerificationLevel VerificationLevel { get; } + /// Gets the level of content filtering applied to user's content in a Guild. + ExplicitContentFilterLevel ExplicitContentFilterLevel { get; } /// Returns the id of this guild's icon, or null if one is not set. string IconId { get; } /// Returns the url to this guild's icon, or null if one is not set. diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index 0ca1bc236..7bbfbaedc 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API @@ -41,5 +41,7 @@ namespace Discord.API public MfaLevel MfaLevel { get; set; } [JsonProperty("default_message_notifications")] public DefaultMessageNotifications DefaultMessageNotifications { get; set; } + [JsonProperty("explicit_content_filter")] + public ExplicitContentFilterLevel ExplicitContentFilter { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index e6819e8a4..8ad1785f1 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -23,6 +23,7 @@ namespace Discord.Rest public VerificationLevel VerificationLevel { get; private set; } public MfaLevel MfaLevel { get; private set; } public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } + public ExplicitContentFilterLevel ExplicitContentFilter { get; private set; } public ulong? AFKChannelId { get; private set; } public ulong? EmbedChannelId { get; private set; } @@ -70,6 +71,7 @@ namespace Discord.Rest VerificationLevel = model.VerificationLevel; MfaLevel = model.MfaLevel; DefaultMessageNotifications = model.DefaultMessageNotifications; + ExplicitContentFilter = model.ExplicitContentFilter; if (model.Emojis != null) { diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 78ea4004a..68da8c46e 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -40,6 +40,7 @@ namespace Discord.WebSocket public VerificationLevel VerificationLevel { get; private set; } public MfaLevel MfaLevel { get; private set; } public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } + public ExplicitContentFilterLevel ExplicitContentFilter { get; private set; } public int MemberCount { get; internal set; } public int DownloadedMemberCount { get; private set; } internal bool IsAvailable { get; private set; } @@ -210,6 +211,7 @@ namespace Discord.WebSocket VerificationLevel = model.VerificationLevel; MfaLevel = model.MfaLevel; DefaultMessageNotifications = model.DefaultMessageNotifications; + ExplicitContentFilter = model.ExplicitContentFilter; if (model.Emojis != null) { From 977022c4ff614551ef6bff913f8f4d2ebd069fa8 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 19:28:26 -0700 Subject: [PATCH 2/4] re-order properties to match order listed on api docs --- src/Discord.Net.Rest/API/Common/Guild.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index 7bbfbaedc..b9ba1655f 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -29,6 +29,10 @@ namespace Discord.API public ulong? SystemChannelId { get; set; } [JsonProperty("verification_level")] public VerificationLevel VerificationLevel { get; set; } + [JsonProperty("default_message_notifications")] + public DefaultMessageNotifications DefaultMessageNotifications { get; set; } + [JsonProperty("explicit_content_filter")] + public ExplicitContentFilterLevel ExplicitContentFilter { get; set; } [JsonProperty("voice_states")] public VoiceState[] VoiceStates { get; set; } [JsonProperty("roles")] @@ -39,9 +43,5 @@ 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; } - [JsonProperty("explicit_content_filter")] - public ExplicitContentFilterLevel ExplicitContentFilter { get; set; } } } From ad13c80dbbc9e9cb0d1786fe44232ad047ad3328 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 19:32:31 -0700 Subject: [PATCH 3/4] re-order SystemChannelId to match api docs --- src/Discord.Net.Rest/API/Common/Guild.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index b9ba1655f..be45ac3fa 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -25,8 +25,6 @@ namespace Discord.API public bool EmbedEnabled { get; set; } [JsonProperty("embed_channel_id")] public ulong? EmbedChannelId { get; set; } - [JsonProperty("system_channel_id")] - public ulong? SystemChannelId { get; set; } [JsonProperty("verification_level")] public VerificationLevel VerificationLevel { get; set; } [JsonProperty("default_message_notifications")] @@ -43,5 +41,7 @@ namespace Discord.API public string[] Features { get; set; } [JsonProperty("mfa_level")] public MfaLevel MfaLevel { get; set; } + [JsonProperty("system_channel_id")] + public ulong? SystemChannelId { get; set; } } } From 01a23279ee0021c0e949900fa67b322ab3ad58a1 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Fri, 28 Sep 2018 21:03:20 -0700 Subject: [PATCH 4/4] Implement ApplicationId in Guild model --- src/Discord.Net.Core/Entities/Guilds/IGuild.cs | 4 +++- src/Discord.Net.Rest/API/Common/Guild.cs | 2 ++ src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs | 4 +++- src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index d64297a1e..bce43974b 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -20,7 +20,7 @@ namespace Discord /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. VerificationLevel VerificationLevel { get; } /// Gets the level of content filtering applied to user's content in a Guild. - ExplicitContentFilterLevel ExplicitContentFilterLevel { get; } + ExplicitContentFilterLevel ExplicitContentFilter { get; } /// Returns the id of this guild's icon, or null if one is not set. string IconId { get; } /// Returns the url to this guild's icon, or null if one is not set. @@ -40,6 +40,8 @@ namespace Discord ulong? EmbedChannelId { get; } /// Gets the id of the channel where randomized welcome messages are sent, or null if not. ulong? SystemChannelId { get; } + /// Gets the application id of the guild creator if it is bot-created. + ulong? ApplicationId { get; } /// Gets the id of the user that created this guild. ulong OwnerId { get; } /// Gets the id of the region hosting this guild's voice channels. diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index be45ac3fa..a84b55a93 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -41,6 +41,8 @@ namespace Discord.API public string[] Features { get; set; } [JsonProperty("mfa_level")] public MfaLevel MfaLevel { get; set; } + [JsonProperty("application_id")] + public ulong? ApplicationId { get; set; } [JsonProperty("system_channel_id")] public ulong? SystemChannelId { get; set; } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 8ad1785f1..f3a57899c 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -33,6 +33,7 @@ namespace Discord.Rest public string IconId { get; private set; } public string SplashId { get; private set; } internal bool Available { get; private set; } + public ulong? ApplicationId { get; private set; } public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); @@ -71,7 +72,8 @@ namespace Discord.Rest VerificationLevel = model.VerificationLevel; MfaLevel = model.MfaLevel; DefaultMessageNotifications = model.DefaultMessageNotifications; - ExplicitContentFilter = model.ExplicitContentFilter; + ExplicitContentFilter = model.ExplicitContentFilter; + ApplicationId = model.ApplicationId; if (model.Emojis != null) { diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 68da8c46e..cf4124ccb 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -45,6 +45,7 @@ namespace Discord.WebSocket public int DownloadedMemberCount { get; private set; } internal bool IsAvailable { get; private set; } public bool IsConnected { get; internal set; } + public ulong? ApplicationId { get; internal set; } internal ulong? AFKChannelId { get; private set; } internal ulong? EmbedChannelId { get; private set; } @@ -212,6 +213,7 @@ namespace Discord.WebSocket MfaLevel = model.MfaLevel; DefaultMessageNotifications = model.DefaultMessageNotifications; ExplicitContentFilter = model.ExplicitContentFilter; + ApplicationId = model.ApplicationId; if (model.Emojis != null) {