Skip to content

Commit

Permalink
Fix help command (#133)
Browse files Browse the repository at this point in the history
* Add debug logging

* Add more debug logging

* Add first counter measure

* Try another way

* Remove test code

* Test another thing

* Return
  • Loading branch information
Sella-GH authored Jul 21, 2024
1 parent 29d8a31 commit 962756b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/AzzyBot-Next.Bot/Utilities/AzzyHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public static AzzyHelpRecord GetSingleCommand(IReadOnlyDictionary<string, Comman
ArgumentOutOfRangeException.ThrowIfZero(commands.Count, nameof(commands));
ArgumentException.ThrowIfNullOrWhiteSpace(commandName, nameof(commandName));

return GetCommandGroups(commands, adminServer, approvedDebug, member, true).FirstOrDefault(r => r.Value.Any(c => c.Name == commandName)).Value.FirstOrDefault() ?? throw new InvalidOperationException("Command not found");
string[] parts = commandName.Split(' ');

return GetCommandGroups(commands, adminServer, approvedDebug, member, true).Where(c => c.Key == parts[0]).SelectMany(r => r.Value).FirstOrDefault(c => c.Name == commandName) ?? throw new InvalidOperationException($"Command not found: {commandName}");
}

private static Dictionary<string, List<AzzyHelpRecord>> GetCommandGroups(IReadOnlyDictionary<string, Command> commands, bool adminServer, bool approvedDebug, DiscordMember member, bool singleCommand = false)
Expand Down

0 comments on commit 962756b

Please sign in to comment.