about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs2
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs6
2 files changed, 4 insertions, 4 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs b/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs

index d55c67c..f29d6e9 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs
@@ -6,7 +6,7 @@ namespace LibMatrix.Utilities.Bot.Commands; public class HelpCommand(IServiceProvider services) : ICommand { public string Name { get; } = "help"; - public string[]? Aliases { get; } = new[] { "?" }; + public string[]? Aliases { get; } = ["?"]; public string Description { get; } = "Displays this help message"; public bool Unlisted { get; } 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,