From ee7d348ff1736a3b534bdf1b39667e17fc4c68e2 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 24 Apr 2025 10:07:47 +0200 Subject: Command handling fixes --- .../Services/CommandListenerHostedService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Utilities/LibMatrix.Utilities.Bot/Services') diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs index a6b5654..9fe460b 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs @@ -142,7 +142,9 @@ public class CommandListenerHostedService : IHostedService { .OrderByDescending(x => x.Length) .FirstOrDefault(commandWithoutPrefix.StartsWith); var args = - usedCommand == null ? [] : commandWithoutPrefix[(usedCommand.Length + 1)..].Split(' '); + usedCommand == null || commandWithoutPrefix.Length <= usedCommand.Length + ? [] + : commandWithoutPrefix[(usedCommand.Length + 1)..].Split(' '); var ctx = new CommandContext { Room = room, MessageEvent = evt, @@ -153,8 +155,6 @@ public class CommandListenerHostedService : IHostedService { try { var command = _commands.SingleOrDefault(x => x.Name == ctx.CommandName || x.Aliases?.Contains(ctx.CommandName) == true); if (command == null) { - await room.SendMessageEventAsync( - new RoomMessageEventContent("m.notice", $"Command \"{ctx.CommandName}\" not found!")); return new() { Success = false, Result = CommandResult.CommandResultType.Failure_InvalidCommand, -- cgit 1.5.1