[Refactor] Remove some unnecessary async/await (#2739)
* Remove some unnecessary async/await * More not-so-async stuff * More not-so-async stuff * Fix merge issue
This commit is contained in:
@@ -110,10 +110,10 @@ namespace Discord.WebSocket
|
||||
=> new DiscordSocketApiClient(config.RestClientProvider, config.WebSocketProvider, DiscordRestConfig.UserAgent, config.GatewayHost,
|
||||
useSystemClock: config.UseSystemClock, defaultRatelimitCallback: config.DefaultRatelimitCallback);
|
||||
|
||||
internal async Task AcquireIdentifyLockAsync(int shardId, CancellationToken token)
|
||||
internal Task AcquireIdentifyLockAsync(int shardId, CancellationToken token)
|
||||
{
|
||||
int semaphoreIdx = shardId % _baseConfig.IdentifyMaxConcurrency;
|
||||
await _identifySemaphores[semaphoreIdx].WaitAsync(token).ConfigureAwait(false);
|
||||
return _identifySemaphores[semaphoreIdx].WaitAsync(token);
|
||||
}
|
||||
|
||||
internal void ReleaseIdentifyLock()
|
||||
@@ -198,11 +198,12 @@ namespace Discord.WebSocket
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task StartAsync()
|
||||
=> await Task.WhenAll(_shards.Select(x => x.StartAsync())).ConfigureAwait(false);
|
||||
public override Task StartAsync()
|
||||
=> Task.WhenAll(_shards.Select(x => x.StartAsync()));
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task StopAsync()
|
||||
=> await Task.WhenAll(_shards.Select(x => x.StopAsync())).ConfigureAwait(false);
|
||||
public override Task StopAsync()
|
||||
=> Task.WhenAll(_shards.Select(x => x.StopAsync()));
|
||||
|
||||
public DiscordSocketClient GetShard(int id)
|
||||
{
|
||||
@@ -220,8 +221,8 @@ namespace Discord.WebSocket
|
||||
=> GetShardFor(guild?.Id ?? 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
|
||||
=> await _shards[0].GetApplicationInfoAsync(options).ConfigureAwait(false);
|
||||
public override Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
|
||||
=> _shards[0].GetApplicationInfoAsync(options);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SocketGuild GetGuild(ulong id)
|
||||
@@ -355,16 +356,12 @@ namespace Discord.WebSocket
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
|
||||
{
|
||||
return await _shards[0].GetVoiceRegionsAsync().ConfigureAwait(false);
|
||||
}
|
||||
public override ValueTask<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null)
|
||||
=> _shards[0].GetVoiceRegionsAsync();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async ValueTask<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
|
||||
{
|
||||
return await _shards[0].GetVoiceRegionAsync(id, options).ConfigureAwait(false);
|
||||
}
|
||||
public override ValueTask<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null)
|
||||
=> _shards[0].GetVoiceRegionAsync(id, options);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <exception cref="ArgumentNullException"><paramref name="guilds"/> is <see langword="null"/></exception>
|
||||
@@ -396,14 +393,14 @@ namespace Discord.WebSocket
|
||||
await _shards[i].SetStatusAsync(status).ConfigureAwait(false);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override async Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)
|
||||
public override Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)
|
||||
{
|
||||
IActivity activity = null;
|
||||
if (!string.IsNullOrEmpty(streamUrl))
|
||||
activity = new StreamingGame(name, streamUrl);
|
||||
else if (!string.IsNullOrEmpty(name))
|
||||
activity = new Game(name, type);
|
||||
await SetActivityAsync(activity).ConfigureAwait(false);
|
||||
return SetActivityAsync(activity);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override async Task SetActivityAsync(IActivity activity)
|
||||
|
||||
Reference in New Issue
Block a user