moved some stuff around

This commit is contained in:
Master Kwoth 2017-06-16 01:55:14 +02:00
parent 0cf1d328d3
commit 6bc4bb7803
10 changed files with 41 additions and 35 deletions

View File

@ -250,12 +250,16 @@ namespace NadekoBot.Modules.Gambling
private Task Client_MessageReceived(SocketMessage imsg)
{
var msg = imsg as SocketUserMessage;
if (msg == null)
var _ = Task.Run(() =>
{
var msg = imsg as SocketUserMessage;
if (msg == null)
return Task.CompletedTask;
if ((msg.Author.Id == _client.CurrentUser.Id) || !(imsg.Channel is ITextChannel) || imsg.Channel != _raceChannel)
return Task.CompletedTask;
Interlocked.Increment(ref _messagesSinceGameStarted);
return Task.CompletedTask;
if ((msg.Author.Id == _client.CurrentUser.Id) || !(imsg.Channel is ITextChannel) || imsg.Channel != _raceChannel)
return Task.CompletedTask;
Interlocked.Increment(ref _messagesSinceGameStarted);
});
return Task.CompletedTask;
}

View File

@ -122,7 +122,7 @@ namespace NadekoBot.Modules.Gambling
});
}
return Task.Delay(0);
return Task.CompletedTask;
}
public async Task FlowerReactionEvent(ICommandContext context, int amount)

View File

@ -184,9 +184,8 @@ $@"--
await End().ConfigureAwait(false);
}
private async Task PotentialAcro(SocketMessage arg)
private Task PotentialAcro(SocketMessage arg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -285,6 +284,7 @@ $@"--
_log.Warn(ex);
}
});
return Task.CompletedTask;
}
public async Task End()

View File

@ -117,9 +117,8 @@ namespace NadekoBot.Modules.Games.Hangman
await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false);
}
private async Task PotentialGuess(SocketMessage msg)
private Task PotentialGuess(SocketMessage msg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -194,6 +193,7 @@ namespace NadekoBot.Modules.Games.Hangman
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
public string GetHangman() => $@". ┌─────┐

View File

@ -107,9 +107,8 @@ namespace NadekoBot.Modules.Games.Models
_client.MessageReceived += AnswerReceived;
}
private async Task AnswerReceived(SocketMessage imsg)
private Task AnswerReceived(SocketMessage imsg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -145,6 +144,7 @@ namespace NadekoBot.Modules.Games.Models
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
private bool Judge(int errors, int textLength) => errors <= textLength / 25;

View File

@ -178,9 +178,8 @@ namespace NadekoBot.Modules.Games.Trivia
try { await Channel.SendConfirmAsync(GetText("trivia_game"), GetText("trivia_stopping")).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
}
private async Task PotentialGuess(SocketMessage imsg)
private Task PotentialGuess(SocketMessage imsg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -242,6 +241,7 @@ namespace NadekoBot.Modules.Games.Trivia
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
public string GetLeaderboard()

View File

@ -14,10 +14,10 @@ namespace NadekoBot.Modules
{
protected readonly Logger _log;
protected CultureInfo _cultureInfo;
public readonly string ModuleTypeName;
public readonly string LowerModuleTypeName;
public NadekoStrings _strings { get; set; }
public CommandHandler _cmdHandler { get; set; }
public ILocalization _localization { get; set; }
@ -34,7 +34,7 @@ namespace NadekoBot.Modules
protected override void BeforeExecute()
{
_cultureInfo =_localization.GetCultureInfo(Context.Guild?.Id);
_cultureInfo = _localization.GetCultureInfo(Context.Guild?.Id);
}
//public Task<IUserMessage> ReplyConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null)
@ -56,7 +56,7 @@ namespace NadekoBot.Modules
// var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
// return Context.Channel.SendErrorAsync(title, text, url, footer);
//}
protected string GetText(string key) =>
_strings.GetText(key, _cultureInfo, LowerModuleTypeName);
@ -111,16 +111,20 @@ namespace NadekoBot.Modules
Task MessageReceived(SocketMessage arg)
{
if (!(arg is SocketUserMessage userMsg) ||
!(userMsg.Channel is ITextChannel chan) ||
userMsg.Author.Id != userId ||
userMsg.Channel.Id != channelId)
var _ = Task.Run(() =>
{
return Task.CompletedTask;
}
if (!(arg is SocketUserMessage userMsg) ||
!(userMsg.Channel is ITextChannel chan) ||
userMsg.Author.Id != userId ||
userMsg.Channel.Id != channelId)
{
return Task.CompletedTask;
}
userInputTask.SetResult(arg.Content);
userMsg.DeleteAfter(1);
userInputTask.SetResult(arg.Content);
userMsg.DeleteAfter(1);
return Task.CompletedTask;
});
return Task.CompletedTask;
}
}

View File

@ -187,7 +187,6 @@ namespace NadekoBot.Services
private async Task MessageReceivedHandler(SocketMessage msg)
{
await Task.Yield();
try
{
if (msg.Author.IsBot || !_bot.Ready) //no bots, wait until bot connected and initialized

View File

@ -97,19 +97,18 @@ namespace NadekoBot.Services.Games
private string GetText(ITextChannel ch, string key, params object[] rep)
=> _strings.GetText(key, ch.GuildId, "Games".ToLowerInvariant(), rep);
private async Task PotentialFlowerGeneration(SocketMessage imsg)
private Task PotentialFlowerGeneration(SocketMessage imsg)
{
await Task.Yield();
var msg = imsg as SocketUserMessage;
if (msg == null || msg.Author.IsBot)
return;
return Task.CompletedTask;
var channel = imsg.Channel as ITextChannel;
if (channel == null)
return;
return Task.CompletedTask;
if (!GenerationChannels.Contains(channel.Id))
return;
return Task.CompletedTask;
var _ = Task.Run(async () =>
{
@ -159,7 +158,7 @@ namespace NadekoBot.Services.Games
LogManager.GetCurrentClassLogger().Warn(ex);
}
});
return;
return Task.CompletedTask;
}
}
}

View File

@ -39,9 +39,8 @@ namespace NadekoBot.Services.Searches
_log = LogManager.GetCurrentClassLogger();
//translate commands
_client.MessageReceived += async (msg) =>
_client.MessageReceived += (msg) =>
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -70,6 +69,7 @@ namespace NadekoBot.Services.Searches
}
catch { }
});
return Task.CompletedTask;
};
//pokemon commands