feature: Remove obsolete sync voice regions methods and properties (#1848)

This commit is contained in:
Paulo
2021-05-26 17:59:14 -03:00
committed by GitHub
parent 7a201e9ff1
commit ed8e57320a
3 changed files with 16 additions and 42 deletions

View File

@@ -70,14 +70,6 @@ namespace Discord.WebSocket
/// A read-only collection of private channels that the user currently partakes in. /// A read-only collection of private channels that the user currently partakes in.
/// </returns> /// </returns>
public abstract IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; } public abstract IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels { get; }
/// <summary>
/// Gets a collection of available voice regions.
/// </summary>
/// <returns>
/// A read-only collection of voice regions that the user has access to.
/// </returns>
[Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")]
public abstract IReadOnlyCollection<RestVoiceRegion> VoiceRegions { get; }
internal BaseSocketClient(DiscordSocketConfig config, DiscordRestApiClient client) internal BaseSocketClient(DiscordSocketConfig config, DiscordRestApiClient client)
: base(config, client) => BaseConfig = config; : base(config, client) => BaseConfig = config;
@@ -163,16 +155,6 @@ namespace Discord.WebSocket
/// </returns> /// </returns>
public abstract SocketGuild GetGuild(ulong id); public abstract SocketGuild GetGuild(ulong id);
/// <summary> /// <summary>
/// Gets a voice region.
/// </summary>
/// <param name="id">The identifier of the voice region (e.g. <c>eu-central</c> ).</param>
/// <returns>
/// A REST-based voice region associated with the identifier; <c>null</c> if the voice region is not
/// found.
/// </returns>
[Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")]
public abstract RestVoiceRegion GetVoiceRegion(string id);
/// <summary>
/// Gets all voice regions. /// Gets all voice regions.
/// </summary> /// </summary>
/// <param name="options">The options to be used when sending the request.</param> /// <param name="options">The options to be used when sending the request.</param>
@@ -326,10 +308,14 @@ namespace Discord.WebSocket
=> Task.FromResult<IUser>(GetUser(username, discriminator)); => Task.FromResult<IUser>(GetUser(username, discriminator));
/// <inheritdoc /> /// <inheritdoc />
Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) async Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options)
=> Task.FromResult<IVoiceRegion>(GetVoiceRegion(id)); {
return await GetVoiceRegionAsync(id).ConfigureAwait(false);
}
/// <inheritdoc /> /// <inheritdoc />
Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) async Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IVoiceRegion>>(VoiceRegions); {
return await GetVoiceRegionsAsync().ConfigureAwait(false);
}
} }
} }

View File

@@ -36,9 +36,6 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
public override IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels => GetPrivateChannels().ToReadOnlyCollection(GetPrivateChannelCount); public override IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels => GetPrivateChannels().ToReadOnlyCollection(GetPrivateChannelCount);
public IReadOnlyCollection<DiscordSocketClient> Shards => _shards; public IReadOnlyCollection<DiscordSocketClient> Shards => _shards;
/// <inheritdoc />
[Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")]
public override IReadOnlyCollection<RestVoiceRegion> VoiceRegions => _shards[0].VoiceRegions;
/// <summary> /// <summary>
/// Provides access to a REST-only client with a shared state from this client. /// Provides access to a REST-only client with a shared state from this client.
@@ -263,11 +260,6 @@ namespace Discord.WebSocket
return null; return null;
} }
/// <inheritdoc />
[Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")]
public override RestVoiceRegion GetVoiceRegion(string id)
=> _shards[0].GetVoiceRegion(id);
/// <inheritdoc /> /// <inheritdoc />
public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null) public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
{ {
@@ -431,11 +423,15 @@ namespace Discord.WebSocket
=> Task.FromResult<IUser>(GetUser(username, discriminator)); => Task.FromResult<IUser>(GetUser(username, discriminator));
/// <inheritdoc /> /// <inheritdoc />
Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options) async Task<IReadOnlyCollection<IVoiceRegion>> IDiscordClient.GetVoiceRegionsAsync(RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IVoiceRegion>>(VoiceRegions); {
return await GetVoiceRegionsAsync().ConfigureAwait(false);
}
/// <inheritdoc /> /// <inheritdoc />
Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options) async Task<IVoiceRegion> IDiscordClient.GetVoiceRegionAsync(string id, RequestOptions options)
=> Task.FromResult<IVoiceRegion>(GetVoiceRegion(id)); {
return await GetVoiceRegionAsync(id).ConfigureAwait(false);
}
internal override void Dispose(bool disposing) internal override void Dispose(bool disposing)
{ {

View File

@@ -108,9 +108,6 @@ namespace Discord.WebSocket
/// </returns> /// </returns>
public IReadOnlyCollection<SocketGroupChannel> GroupChannels public IReadOnlyCollection<SocketGroupChannel> GroupChannels
=> State.PrivateChannels.OfType<SocketGroupChannel>().ToImmutableArray(); => State.PrivateChannels.OfType<SocketGroupChannel>().ToImmutableArray();
/// <inheritdoc />
[Obsolete("This property is obsolete, use the GetVoiceRegionsAsync method instead.")]
public override IReadOnlyCollection<RestVoiceRegion> VoiceRegions => GetVoiceRegionsAsync().GetAwaiter().GetResult();
/// <summary> /// <summary>
/// Initializes a new REST/WebSocket-based Discord client. /// Initializes a new REST/WebSocket-based Discord client.
@@ -336,11 +333,6 @@ namespace Discord.WebSocket
internal void RemoveUser(ulong id) internal void RemoveUser(ulong id)
=> State.RemoveUser(id); => State.RemoveUser(id);
/// <inheritdoc />
[Obsolete("This method is obsolete, use GetVoiceRegionAsync instead.")]
public override RestVoiceRegion GetVoiceRegion(string id)
=> GetVoiceRegionAsync(id).GetAwaiter().GetResult();
/// <inheritdoc /> /// <inheritdoc />
public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null) public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
{ {