Removed some useless code

This commit is contained in:
Kwoth
2022-02-07 17:52:57 +01:00
parent 0008eabdd2
commit 1622eb05c9
5 changed files with 15 additions and 21 deletions

View File

@@ -111,11 +111,10 @@ namespace NadekoBot.Coordinator
return new DieReply(); return new DieReply();
} }
public override async Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context) public override Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context)
{ {
await Task.Yield(); var error = string.Empty;
string error = string.Empty; var success = true;
bool success = true;
try try
{ {
_runner.SetConfigText(request.ConfigYml); _runner.SetConfigText(request.ConfigYml);
@@ -126,11 +125,11 @@ namespace NadekoBot.Coordinator
success = false; success = false;
} }
return new(new() return Task.FromResult<SetConfigTextReply>(new(new()
{ {
Success = success, Success = success,
Error = error Error = error
}); }));
} }
public override Task<GetConfigTextReply> GetConfigText(GetConfigTextRequest request, ServerCallContext context) public override Task<GetConfigTextReply> GetConfigText(GetConfigTextRequest request, ServerCallContext context)

View File

@@ -125,13 +125,12 @@ public class GameStatusEvent : ICurrencyEvent
await StopEvent(); await StopEvent();
} }
public async Task StopEvent() public Task StopEvent()
{ {
await Task.Yield();
lock (_stopLock) lock (_stopLock)
{ {
if (Stopped) if (Stopped)
return; return Task.CompletedTask;
Stopped = true; Stopped = true;
_client.MessageDeleted -= OnMessageDeleted; _client.MessageDeleted -= OnMessageDeleted;
_client.MessageReceived -= HandleMessage; _client.MessageReceived -= HandleMessage;
@@ -146,6 +145,8 @@ public class GameStatusEvent : ICurrencyEvent
_ = OnEnded?.Invoke(_guild.Id); _ = OnEnded?.Invoke(_guild.Id);
} }
return Task.CompletedTask;
} }
private Task HandleMessage(SocketMessage message) private Task HandleMessage(SocketMessage message)

View File

@@ -122,13 +122,13 @@ public class ReactionEvent : ICurrencyEvent
await StopEvent(); await StopEvent();
} }
public async Task StopEvent() public Task StopEvent()
{ {
await Task.Yield();
lock (_stopLock) lock (_stopLock)
{ {
if (Stopped) if (Stopped)
return; return Task.CompletedTask;
Stopped = true; Stopped = true;
_client.MessageDeleted -= OnMessageDeleted; _client.MessageDeleted -= OnMessageDeleted;
_client.ReactionAdded -= HandleReaction; _client.ReactionAdded -= HandleReaction;
@@ -142,6 +142,8 @@ public class ReactionEvent : ICurrencyEvent
_ = OnEnded?.Invoke(_guild.Id); _ = OnEnded?.Invoke(_guild.Id);
} }
return Task.CompletedTask;
} }
private Task HandleReaction( private Task HandleReaction(

View File

@@ -102,7 +102,6 @@ public class PermissionService : ILateBlocker, INService
var channel = ctx.Channel; var channel = ctx.Channel;
var commandName = command.Name.ToLowerInvariant(); var commandName = command.Name.ToLowerInvariant();
await Task.Yield();
if (guild is null) if (guild is null)
return false; return false;

View File

@@ -197,12 +197,12 @@ public class GoogleApiService : IGoogleApiService, INService
// todo future add quota users // todo future add quota users
public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 1) public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 1)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(id)) if (string.IsNullOrWhiteSpace(id))
throw new ArgumentNullException(nameof(id)); throw new ArgumentNullException(nameof(id));
if (count <= 0) if (count <= 0)
throw new ArgumentOutOfRangeException(nameof(count)); throw new ArgumentOutOfRangeException(nameof(count));
var query = _yt.Search.List("snippet"); var query = _yt.Search.List("snippet");
query.MaxResults = count; query.MaxResults = count;
query.RelatedToVideoId = id; query.RelatedToVideoId = id;
@@ -212,7 +212,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<IEnumerable<string>> GetVideoLinksByKeywordAsync(string keywords, int count = 1) public async Task<IEnumerable<string>> GetVideoLinksByKeywordAsync(string keywords, int count = 1)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(keywords)) if (string.IsNullOrWhiteSpace(keywords))
throw new ArgumentNullException(nameof(keywords)); throw new ArgumentNullException(nameof(keywords));
@@ -231,7 +230,6 @@ public class GoogleApiService : IGoogleApiService, INService
string keywords, string keywords,
int count = 1) int count = 1)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(keywords)) if (string.IsNullOrWhiteSpace(keywords))
throw new ArgumentNullException(nameof(keywords)); throw new ArgumentNullException(nameof(keywords));
@@ -251,7 +249,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<string> ShortenUrl(string url) public async Task<string> ShortenUrl(string url)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(url)) if (string.IsNullOrWhiteSpace(url))
throw new ArgumentNullException(nameof(url)); throw new ArgumentNullException(nameof(url));
@@ -280,7 +277,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<IEnumerable<string>> GetPlaylistTracksAsync(string playlistId, int count = 50) public async Task<IEnumerable<string>> GetPlaylistTracksAsync(string playlistId, int count = 50)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(playlistId)) if (string.IsNullOrWhiteSpace(playlistId))
throw new ArgumentNullException(nameof(playlistId)); throw new ArgumentNullException(nameof(playlistId));
@@ -312,7 +308,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<IReadOnlyDictionary<string, TimeSpan>> GetVideoDurationsAsync(IEnumerable<string> videoIds) public async Task<IReadOnlyDictionary<string, TimeSpan>> GetVideoDurationsAsync(IEnumerable<string> videoIds)
{ {
await Task.Yield();
var videoIdsList = videoIds as List<string> ?? videoIds.ToList(); var videoIdsList = videoIds as List<string> ?? videoIds.ToList();
var toReturn = new Dictionary<string, TimeSpan>(); var toReturn = new Dictionary<string, TimeSpan>();
@@ -339,7 +334,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<ImageResult> GetImageAsync(string query) public async Task<ImageResult> GetImageAsync(string query)
{ {
await Task.Yield();
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException(nameof(query)); throw new ArgumentNullException(nameof(query));
@@ -359,7 +353,6 @@ public class GoogleApiService : IGoogleApiService, INService
public async Task<string> Translate(string sourceText, string sourceLanguage, string targetLanguage) public async Task<string> Translate(string sourceText, string sourceLanguage, string targetLanguage)
{ {
await Task.Yield();
string text; string text;
if (!Languages.ContainsKey(sourceLanguage) || !Languages.ContainsKey(targetLanguage)) if (!Languages.ContainsKey(sourceLanguage) || !Languages.ContainsKey(targetLanguage))