From ed8e57320a4a6d082aaabcc3b15fa07199c52316 Mon Sep 17 00:00:00 2001 From: Paulo Date: Wed, 26 May 2021 17:59:14 -0300 Subject: [PATCH] feature: Remove obsolete sync voice regions methods and properties (#1848) --- src/Discord.Net.WebSocket/BaseSocketClient.cs | 30 +++++-------------- .../DiscordShardedClient.cs | 20 +++++-------- .../DiscordSocketClient.cs | 8 ----- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.cs b/src/Discord.Net.WebSocket/BaseSocketClient.cs index 1cfcaa1ee..b1b430178 100644 --- a/src/Discord.Net.WebSocket/BaseSocketClient.cs +++ b/src/Discord.Net.WebSocket/BaseSocketClient.cs @@ -70,14 +70,6 @@ namespace Discord.WebSocket /// A read-only collection of private channels that the user currently partakes in. /// public abstract IReadOnlyCollection PrivateChannels { get; } - /// - /// Gets a collection of available voice regions. - /// - /// - /// A read-only collection of voice regions that the user has access to. - /// - [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] - public abstract IReadOnlyCollection VoiceRegions { get; } internal BaseSocketClient(DiscordSocketConfig config, DiscordRestApiClient client) : base(config, client) => BaseConfig = config; @@ -163,16 +155,6 @@ namespace Discord.WebSocket /// public abstract SocketGuild GetGuild(ulong id); /// - /// Gets a voice region. - /// - /// The identifier of the voice region (e.g. eu-central ). - /// - /// A REST-based voice region associated with the identifier; null if the voice region is not - /// found. - /// - [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] - public abstract RestVoiceRegion GetVoiceRegion(string id); - /// /// Gets all voice regions. /// /// The options to be used when sending the request. @@ -326,10 +308,14 @@ namespace Discord.WebSocket => Task.FromResult(GetUser(username, discriminator)); /// - Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) - => Task.FromResult(GetVoiceRegion(id)); + async Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) + { + return await GetVoiceRegionAsync(id).ConfigureAwait(false); + } /// - Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) - => Task.FromResult>(VoiceRegions); + async Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) + { + return await GetVoiceRegionsAsync().ConfigureAwait(false); + } } } diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index c406ead62..ea50a571e 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -36,9 +36,6 @@ namespace Discord.WebSocket /// public override IReadOnlyCollection PrivateChannels => GetPrivateChannels().ToReadOnlyCollection(GetPrivateChannelCount); public IReadOnlyCollection Shards => _shards; - /// - [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] - public override IReadOnlyCollection VoiceRegions => _shards[0].VoiceRegions; /// /// Provides access to a REST-only client with a shared state from this client. @@ -263,11 +260,6 @@ namespace Discord.WebSocket return null; } - /// - [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] - public override RestVoiceRegion GetVoiceRegion(string id) - => _shards[0].GetVoiceRegion(id); - /// public override async ValueTask> GetVoiceRegionsAsync(RequestOptions options = null) { @@ -431,11 +423,15 @@ namespace Discord.WebSocket => Task.FromResult(GetUser(username, discriminator)); /// - Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) - => Task.FromResult>(VoiceRegions); + async Task> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) + { + return await GetVoiceRegionsAsync().ConfigureAwait(false); + } /// - Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) - => Task.FromResult(GetVoiceRegion(id)); + async Task IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) + { + return await GetVoiceRegionAsync(id).ConfigureAwait(false); + } internal override void Dispose(bool disposing) { diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 7a1aaa6d6..d4ca6329d 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -108,9 +108,6 @@ namespace Discord.WebSocket /// public IReadOnlyCollection GroupChannels => State.PrivateChannels.OfType().ToImmutableArray(); - /// - [Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")] - public override IReadOnlyCollection VoiceRegions => GetVoiceRegionsAsync().GetAwaiter().GetResult(); /// /// Initializes a new REST/WebSocket-based Discord client. @@ -336,11 +333,6 @@ namespace Discord.WebSocket internal void RemoveUser(ulong id) => State.RemoveUser(id); - /// - [Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")] - public override RestVoiceRegion GetVoiceRegion(string id) - => GetVoiceRegionAsync(id).GetAwaiter().GetResult(); - /// public override async ValueTask> GetVoiceRegionsAsync(RequestOptions options = null) {