From 3d317764b889e2a92c82f007f80c898ec386c59b Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 24 Apr 2025 03:45:11 +0200 Subject: Fix args when using commands with spaces --- .../Services/CommandListenerHostedService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Utilities') diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs index 750e6a3..a6b5654 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs @@ -141,11 +141,13 @@ public class CommandListenerHostedService : IHostedService { .SelectMany(x => [x.Name, ..x.Aliases ?? []]) .OrderByDescending(x => x.Length) .FirstOrDefault(commandWithoutPrefix.StartsWith); + var args = + usedCommand == null ? [] : commandWithoutPrefix[(usedCommand.Length + 1)..].Split(' '); var ctx = new CommandContext { Room = room, - MessageEvent = @evt, + MessageEvent = evt, Homeserver = _hs, - Args = commandWithoutPrefix.Split(' ').Length == 1 ? [] : commandWithoutPrefix.Split(' ')[1..], + Args = args, CommandName = usedCommand ?? commandWithoutPrefix.Split(' ')[0] }; try { -- cgit 1.5.1