Skip to content

Commit

Permalink
More improving of Linq
Browse files Browse the repository at this point in the history
  • Loading branch information
Sella-GH committed Jun 4, 2024
1 parent 8948c55 commit 5ae0a4d
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions AzzyBot-Next/Utilities/AzzyHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,7 @@ public static AzzyHelpRecord GetSingleCommand(IReadOnlyDictionary<string, Comman
ArgumentOutOfRangeException.ThrowIfZero(commands.Count, nameof(commands));
ArgumentException.ThrowIfNullOrWhiteSpace(commandName, nameof(commandName));

foreach (KeyValuePair<string, List<AzzyHelpRecord>> record in GetCommandGroups(commands, adminServer, approvedDebug, member))
{
foreach (AzzyHelpRecord subRecord in record.Value)
{
if (subRecord.Name == commandName)
return subRecord;
}
}

throw new InvalidOperationException("Command not found");
return GetCommandGroups(commands, adminServer, approvedDebug, member).FirstOrDefault(r => r.Value.Any(c => c.Name == commandName)).Value.FirstOrDefault() ?? throw new InvalidOperationException("Command not found");
}

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

0 comments on commit 5ae0a4d

Please sign in to comment.