Skip to content

Commit

Permalink
Fix flaws in help handler
Browse files Browse the repository at this point in the history
Fixes aliases not showing for some commands + help failing to show for commands that are not suffixed with 'textcmd'
  • Loading branch information
FloatingMilkshake committed Jan 2, 2025
1 parent 1ae753c commit 15f5e94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Commands/GlobalCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task Help(CommandContext ctx, [Description("Command to provide help

StringComparison comparison = StringComparison.InvariantCultureIgnoreCase;
StringComparer comparer = StringComparer.InvariantCultureIgnoreCase;
cmd = searchIn.FirstOrDefault(xc => xc.Name.Equals(commandSplit[i], comparison) || ((xc.Attributes.FirstOrDefault(x => x is TextAliasAttribute) as TextAliasAttribute)?.Aliases.Contains(commandSplit[i].Replace("textcmd", ""), comparer) ?? false));
cmd = searchIn.FirstOrDefault(xc => xc.Name.Equals(commandSplit[i], comparison) || xc.Name.Equals(commandSplit[i].Replace("textcmd", ""), comparison) || ((xc.Attributes.FirstOrDefault(x => x is TextAliasAttribute) as TextAliasAttribute)?.Aliases.Contains(commandSplit[i].Replace("textcmd", ""), comparer) ?? false));

if (cmd is null)
{
Expand Down Expand Up @@ -95,7 +95,7 @@ await ctx.RespondAsync(
}

var aliases = cmd.Method?.GetCustomAttributes<TextAliasAttribute>().FirstOrDefault()?.Aliases ?? (cmd.Attributes.FirstOrDefault(x => x is TextAliasAttribute) as TextAliasAttribute)?.Aliases ?? null;
if (aliases is not null && aliases.Length > 1)
if (aliases is not null && (aliases.Length > 1 || (aliases.Length == 1 && aliases[0] != cmd.Name.Replace("textcmd", ""))))
{
var aliasStr = "";
foreach (var alias in aliases)
Expand Down

0 comments on commit 15f5e94

Please sign in to comment.