diff --git a/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs b/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs index e9e914b67..63dd35ac2 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs @@ -17,5 +17,7 @@ namespace Discord.API.Gateway public Optional ShardingParams { get; set; } [JsonProperty("presence")] public Optional Presence { get; set; } + [JsonProperty("guild_subscriptions")] + public Optional GuildSubscriptions { get; set; } } } diff --git a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs index d80cbc0d8..6e2c19ffa 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs @@ -245,6 +245,7 @@ namespace Discord.API Properties = props, LargeThreshold = largeThreshold, Presence = args + GuildSubscriptions = guildSubscriptions }; if (totalShards > 1) msg.ShardingParams = new int[] { shardID, totalShards }; diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index c1f8ac34d..91a7744ab 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -43,6 +43,7 @@ namespace Discord.WebSocket private DateTimeOffset? _statusSince; private RestApplication _applicationInfo; private bool _isDisposed; + private bool _guildSubscriptions; /// /// Provides access to a REST-only client with a shared state from this client. @@ -135,6 +136,7 @@ namespace Discord.WebSocket State = new ClientState(0, 0); Rest = new DiscordSocketRestClient(config, ApiClient); _heartbeatTimes = new ConcurrentQueue(); + _guildSubscriptions = config.GuildSubscriptions; _stateLock = new SemaphoreSlim(1, 1); _gatewayLogger = LogManager.CreateLogger(ShardId == 0 && TotalShards == 1 ? "Gateway" : $"Shard #{ShardId}"); diff --git a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs index 3610afd13..98ab0ef9b 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs @@ -77,7 +77,7 @@ namespace Discord.WebSocket /// /// By default, the Discord gateway will only send offline members if a guild has less than a certain number /// of members (determined by in this library). This behaviour is why - /// sometimes a user may be missing from the WebSocket cache for collections such as + /// sometimes a user may be missing from the WebSocket cache for collections such as /// . /// /// @@ -86,7 +86,7 @@ namespace Discord.WebSocket /// downloaded to the WebSocket cache. /// /// - /// For more information, please see + /// For more information, please see /// Request Guild Members /// on the official Discord API documentation. /// @@ -95,7 +95,7 @@ namespace Discord.WebSocket /// traffic. If you are using the command system, the default user TypeReader may fail to find the user /// due to this issue. This may be resolved at v3 of the library. Until then, you may want to consider /// overriding the TypeReader and use - /// + /// /// or /// as a backup. /// @@ -119,6 +119,11 @@ namespace Discord.WebSocket /// public bool? ExclusiveBulkDelete { get; set; } = null; + /// + /// Gets or sets enabling dispatching of guild subscription events e.g. presence and typing events. + /// + public bool GuildSubscriptions { get; set; } = true; + /// /// Initializes a default configuration. /// diff --git a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs index 1623d94f2..12ec1a0bd 100644 --- a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs +++ b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Xunit; namespace Discord @@ -250,7 +249,7 @@ namespace Discord .WithFooter("This is the footer", url) .WithImageUrl(url) .WithThumbnailUrl(url) - .WithTimestamp(DateTime.MinValue) + .WithTimestamp(DateTimeOffset.MinValue) .WithTitle("This is the title") .WithUrl(url) .AddField("Field 1", "Inline", true)