moved some stuff around
This commit is contained in:
parent
0cf1d328d3
commit
6bc4bb7803
@ -250,12 +250,16 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
private Task Client_MessageReceived(SocketMessage imsg)
|
private Task Client_MessageReceived(SocketMessage imsg)
|
||||||
{
|
{
|
||||||
var msg = imsg as SocketUserMessage;
|
var _ = Task.Run(() =>
|
||||||
if (msg == null)
|
{
|
||||||
|
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;
|
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;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.Delay(0);
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FlowerReactionEvent(ICommandContext context, int amount)
|
public async Task FlowerReactionEvent(ICommandContext context, int amount)
|
||||||
|
@ -184,9 +184,8 @@ $@"--
|
|||||||
await End().ConfigureAwait(false);
|
await End().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PotentialAcro(SocketMessage arg)
|
private Task PotentialAcro(SocketMessage arg)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -285,6 +284,7 @@ $@"--
|
|||||||
_log.Warn(ex);
|
_log.Warn(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task End()
|
public async Task End()
|
||||||
|
@ -117,9 +117,8 @@ namespace NadekoBot.Modules.Games.Hangman
|
|||||||
await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false);
|
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 () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -194,6 +193,7 @@ namespace NadekoBot.Modules.Games.Hangman
|
|||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
});
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetHangman() => $@". ┌─────┐
|
public string GetHangman() => $@". ┌─────┐
|
||||||
|
@ -107,9 +107,8 @@ namespace NadekoBot.Modules.Games.Models
|
|||||||
_client.MessageReceived += AnswerReceived;
|
_client.MessageReceived += AnswerReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AnswerReceived(SocketMessage imsg)
|
private Task AnswerReceived(SocketMessage imsg)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -145,6 +144,7 @@ namespace NadekoBot.Modules.Games.Models
|
|||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
});
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Judge(int errors, int textLength) => errors <= textLength / 25;
|
private bool Judge(int errors, int textLength) => errors <= textLength / 25;
|
||||||
|
@ -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); }
|
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 () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -242,6 +241,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
|||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
});
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLeaderboard()
|
public string GetLeaderboard()
|
||||||
|
@ -14,10 +14,10 @@ namespace NadekoBot.Modules
|
|||||||
{
|
{
|
||||||
protected readonly Logger _log;
|
protected readonly Logger _log;
|
||||||
protected CultureInfo _cultureInfo;
|
protected CultureInfo _cultureInfo;
|
||||||
|
|
||||||
public readonly string ModuleTypeName;
|
public readonly string ModuleTypeName;
|
||||||
public readonly string LowerModuleTypeName;
|
public readonly string LowerModuleTypeName;
|
||||||
|
|
||||||
public NadekoStrings _strings { get; set; }
|
public NadekoStrings _strings { get; set; }
|
||||||
public CommandHandler _cmdHandler { get; set; }
|
public CommandHandler _cmdHandler { get; set; }
|
||||||
public ILocalization _localization { get; set; }
|
public ILocalization _localization { get; set; }
|
||||||
@ -34,7 +34,7 @@ namespace NadekoBot.Modules
|
|||||||
|
|
||||||
protected override void BeforeExecute()
|
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)
|
//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);
|
// var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
|
||||||
// return Context.Channel.SendErrorAsync(title, text, url, footer);
|
// return Context.Channel.SendErrorAsync(title, text, url, footer);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
protected string GetText(string key) =>
|
protected string GetText(string key) =>
|
||||||
_strings.GetText(key, _cultureInfo, LowerModuleTypeName);
|
_strings.GetText(key, _cultureInfo, LowerModuleTypeName);
|
||||||
|
|
||||||
@ -111,16 +111,20 @@ namespace NadekoBot.Modules
|
|||||||
|
|
||||||
Task MessageReceived(SocketMessage arg)
|
Task MessageReceived(SocketMessage arg)
|
||||||
{
|
{
|
||||||
if (!(arg is SocketUserMessage userMsg) ||
|
var _ = Task.Run(() =>
|
||||||
!(userMsg.Channel is ITextChannel chan) ||
|
|
||||||
userMsg.Author.Id != userId ||
|
|
||||||
userMsg.Channel.Id != channelId)
|
|
||||||
{
|
{
|
||||||
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);
|
userInputTask.SetResult(arg.Content);
|
||||||
userMsg.DeleteAfter(1);
|
userMsg.DeleteAfter(1);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,6 @@ namespace NadekoBot.Services
|
|||||||
|
|
||||||
private async Task MessageReceivedHandler(SocketMessage msg)
|
private async Task MessageReceivedHandler(SocketMessage msg)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (msg.Author.IsBot || !_bot.Ready) //no bots, wait until bot connected and initialized
|
if (msg.Author.IsBot || !_bot.Ready) //no bots, wait until bot connected and initialized
|
||||||
|
@ -97,19 +97,18 @@ namespace NadekoBot.Services.Games
|
|||||||
private string GetText(ITextChannel ch, string key, params object[] rep)
|
private string GetText(ITextChannel ch, string key, params object[] rep)
|
||||||
=> _strings.GetText(key, ch.GuildId, "Games".ToLowerInvariant(), 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;
|
var msg = imsg as SocketUserMessage;
|
||||||
if (msg == null || msg.Author.IsBot)
|
if (msg == null || msg.Author.IsBot)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var channel = imsg.Channel as ITextChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
if (!GenerationChannels.Contains(channel.Id))
|
if (!GenerationChannels.Contains(channel.Id))
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@ -159,7 +158,7 @@ namespace NadekoBot.Services.Games
|
|||||||
LogManager.GetCurrentClassLogger().Warn(ex);
|
LogManager.GetCurrentClassLogger().Warn(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,8 @@ namespace NadekoBot.Services.Searches
|
|||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
//translate commands
|
//translate commands
|
||||||
_client.MessageReceived += async (msg) =>
|
_client.MessageReceived += (msg) =>
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -70,6 +69,7 @@ namespace NadekoBot.Services.Searches
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
});
|
});
|
||||||
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
//pokemon commands
|
//pokemon commands
|
||||||
|
Loading…
Reference in New Issue
Block a user