performance improvements?

This commit is contained in:
Kwoth 2017-02-02 14:16:28 +01:00
parent a0e23b4c2c
commit dfbabea8b9
2 changed files with 87 additions and 78 deletions

View File

@ -38,7 +38,9 @@ namespace NadekoBot.Modules.Administration
}
private static async Task DelMsgOnCmd_Handler(SocketUserMessage msg, CommandInfo cmd)
private static Task DelMsgOnCmd_Handler(SocketUserMessage msg, CommandInfo cmd)
{
var _ = Task.Run(async () =>
{
try
{
@ -52,6 +54,8 @@ namespace NadekoBot.Modules.Administration
{
_log.Warn(ex, "Delmsgoncmd errored...");
}
});
return Task.CompletedTask;
}
[NadekoCommand, Usage, Description, Aliases]

View File

@ -105,9 +105,8 @@ namespace NadekoBot.Services
BlacklistCommands.BlacklistedUsers.Contains(usrMsg.Author.Id);
const float oneThousandth = 1.0f / 1000;
private async Task LogSuccessfulExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int ticks)
private Task LogSuccessfulExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int ticks)
{
await CommandExecuted(usrMsg, exec.CommandInfo).ConfigureAwait(false);
_log.Info("Command Executed after {4}s\n\t" +
"User: {0}\n\t" +
"Server: {1}\n\t" +
@ -118,6 +117,7 @@ namespace NadekoBot.Services
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
usrMsg.Content, // {3}
ticks * oneThousandth);
return Task.CompletedTask;
}
private void LogErroredExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int ticks)
@ -184,7 +184,9 @@ namespace NadekoBot.Services
return false;
}
private async Task MessageReceivedHandler(SocketMessage msg)
private Task MessageReceivedHandler(SocketMessage msg)
{
var _ = Task.Run(async () =>
{
try
{
@ -235,6 +237,7 @@ namespace NadekoBot.Services
if (exec.Result.IsSuccess)
{
await CommandExecuted(usrMsg, exec.CommandInfo).ConfigureAwait(false);
await LogSuccessfulExecution(usrMsg, exec, channel, execTime).ConfigureAwait(false);
}
else if (!exec.Result.IsSuccess && exec.Result.Error != CommandError.UnknownCommand)
@ -271,6 +274,8 @@ namespace NadekoBot.Services
_log.Warn(ex.InnerException);
}
}
});
return Task.CompletedTask;
}
public Task<ExecuteCommandResult> ExecuteCommandAsync(CommandContext context, int argPos, IDependencyMap dependencyMap = null, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)