From e5609a0708f877e06ef2b1be5245dddfc7fa9faf Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 22 Aug 2017 05:47:57 +0200 Subject: [PATCH] .prefix bugfix, #1524 --- src/NadekoBot/Services/CommandHandler.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 21309283..ad51c579 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -43,6 +43,7 @@ namespace NadekoBot.Services public event Func CommandExecuted = delegate { return Task.CompletedTask; }; public event Func CommandErrored = delegate { return Task.CompletedTask; }; + public event Func OnMessageNoTrigger = delegate { return Task.CompletedTask; }; //userid/msg count public ConcurrentDictionary UserMessagesSent { get; } = new ConcurrentDictionary(); @@ -261,13 +262,13 @@ namespace NadekoBot.Services } } var prefix = GetPrefix(guild?.Id); - var isPrefixCommand = messageContent == ".prefix"; + var isPrefixCommand = messageContent.StartsWith(".prefix"); // execute the command and measure the time it took if (messageContent.StartsWith(prefix) || isPrefixCommand) { var result = await ExecuteCommandAsync(new CommandContext(_client, usrMsg), messageContent, isPrefixCommand ? 1 : prefix.Length, _services, MultiMatchHandling.Best); execTime = Environment.TickCount - execTime; - + if (result.Success) { await LogSuccessfulExecution(usrMsg, channel as ITextChannel, exec2, exec3, execTime).ConfigureAwait(false); @@ -276,11 +277,14 @@ namespace NadekoBot.Services } else if (result.Error != null) { - LogErroredExecution(result.Error, usrMsg, channel as ITextChannel, exec2, exec3, execTime); + LogErroredExecution(result.Error, usrMsg, channel as ITextChannel, exec2, exec3, execTime); if (guild != null) await CommandErrored(result.Info, channel as ITextChannel, result.Error); } - + } + else + { + await OnMessageNoTrigger(usrMsg).ConfigureAwait(false); } foreach (var svc in _services)