diff --git a/src/NadekoBot.Coordinator/Services/CoordinatorService.cs b/src/NadekoBot.Coordinator/Services/CoordinatorService.cs index f4d7c5b0f..b5fbac223 100644 --- a/src/NadekoBot.Coordinator/Services/CoordinatorService.cs +++ b/src/NadekoBot.Coordinator/Services/CoordinatorService.cs @@ -111,11 +111,10 @@ namespace NadekoBot.Coordinator return new DieReply(); } - public override async Task SetConfigText(SetConfigTextRequest request, ServerCallContext context) + public override Task SetConfigText(SetConfigTextRequest request, ServerCallContext context) { - await Task.Yield(); - string error = string.Empty; - bool success = true; + var error = string.Empty; + var success = true; try { _runner.SetConfigText(request.ConfigYml); @@ -126,11 +125,11 @@ namespace NadekoBot.Coordinator success = false; } - return new(new() + return Task.FromResult(new(new() { Success = success, Error = error - }); + })); } public override Task GetConfigText(GetConfigTextRequest request, ServerCallContext context) diff --git a/src/NadekoBot/Modules/Gambling/Events/GameStatusEvent.cs b/src/NadekoBot/Modules/Gambling/Events/GameStatusEvent.cs index 55cae8773..105807ba8 100644 --- a/src/NadekoBot/Modules/Gambling/Events/GameStatusEvent.cs +++ b/src/NadekoBot/Modules/Gambling/Events/GameStatusEvent.cs @@ -125,13 +125,12 @@ public class GameStatusEvent : ICurrencyEvent await StopEvent(); } - public async Task StopEvent() + public Task StopEvent() { - await Task.Yield(); lock (_stopLock) { if (Stopped) - return; + return Task.CompletedTask; Stopped = true; _client.MessageDeleted -= OnMessageDeleted; _client.MessageReceived -= HandleMessage; @@ -146,6 +145,8 @@ public class GameStatusEvent : ICurrencyEvent _ = OnEnded?.Invoke(_guild.Id); } + + return Task.CompletedTask; } private Task HandleMessage(SocketMessage message) diff --git a/src/NadekoBot/Modules/Gambling/Events/ReactionEvent.cs b/src/NadekoBot/Modules/Gambling/Events/ReactionEvent.cs index 72bbd7d2c..1651ca36b 100644 --- a/src/NadekoBot/Modules/Gambling/Events/ReactionEvent.cs +++ b/src/NadekoBot/Modules/Gambling/Events/ReactionEvent.cs @@ -122,13 +122,13 @@ public class ReactionEvent : ICurrencyEvent await StopEvent(); } - public async Task StopEvent() + public Task StopEvent() { - await Task.Yield(); lock (_stopLock) { if (Stopped) - return; + return Task.CompletedTask; + Stopped = true; _client.MessageDeleted -= OnMessageDeleted; _client.ReactionAdded -= HandleReaction; @@ -142,6 +142,8 @@ public class ReactionEvent : ICurrencyEvent _ = OnEnded?.Invoke(_guild.Id); } + + return Task.CompletedTask; } private Task HandleReaction( diff --git a/src/NadekoBot/Modules/Permissions/PermissionsService.cs b/src/NadekoBot/Modules/Permissions/PermissionsService.cs index 5ff91495a..05db976ad 100644 --- a/src/NadekoBot/Modules/Permissions/PermissionsService.cs +++ b/src/NadekoBot/Modules/Permissions/PermissionsService.cs @@ -102,7 +102,6 @@ public class PermissionService : ILateBlocker, INService var channel = ctx.Channel; var commandName = command.Name.ToLowerInvariant(); - await Task.Yield(); if (guild is null) return false; diff --git a/src/NadekoBot/Services/Impl/GoogleApiService.cs b/src/NadekoBot/Services/Impl/GoogleApiService.cs index 2fbeaa87f..1d916c74a 100644 --- a/src/NadekoBot/Services/Impl/GoogleApiService.cs +++ b/src/NadekoBot/Services/Impl/GoogleApiService.cs @@ -197,12 +197,12 @@ public class GoogleApiService : IGoogleApiService, INService // todo future add quota users public async Task> GetRelatedVideosAsync(string id, int count = 1) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id)); if (count <= 0) throw new ArgumentOutOfRangeException(nameof(count)); + var query = _yt.Search.List("snippet"); query.MaxResults = count; query.RelatedToVideoId = id; @@ -212,7 +212,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task> GetVideoLinksByKeywordAsync(string keywords, int count = 1) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(keywords)) throw new ArgumentNullException(nameof(keywords)); @@ -231,7 +230,6 @@ public class GoogleApiService : IGoogleApiService, INService string keywords, int count = 1) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(keywords)) throw new ArgumentNullException(nameof(keywords)); @@ -251,7 +249,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task ShortenUrl(string url) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(url)) throw new ArgumentNullException(nameof(url)); @@ -280,7 +277,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task> GetPlaylistTracksAsync(string playlistId, int count = 50) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(playlistId)) throw new ArgumentNullException(nameof(playlistId)); @@ -312,7 +308,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task> GetVideoDurationsAsync(IEnumerable videoIds) { - await Task.Yield(); var videoIdsList = videoIds as List ?? videoIds.ToList(); var toReturn = new Dictionary(); @@ -339,7 +334,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task GetImageAsync(string query) { - await Task.Yield(); if (string.IsNullOrWhiteSpace(query)) throw new ArgumentNullException(nameof(query)); @@ -359,7 +353,6 @@ public class GoogleApiService : IGoogleApiService, INService public async Task Translate(string sourceText, string sourceLanguage, string targetLanguage) { - await Task.Yield(); string text; if (!Languages.ContainsKey(sourceLanguage) || !Languages.ContainsKey(targetLanguage))