Skip to content

Commit 15f5e94

Browse files
Fix flaws in help handler
Fixes aliases not showing for some commands + help failing to show for commands that are not suffixed with 'textcmd'
1 parent 1ae753c commit 15f5e94

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Commands/GlobalCmds.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task Help(CommandContext ctx, [Description("Command to provide help
4141

4242
StringComparison comparison = StringComparison.InvariantCultureIgnoreCase;
4343
StringComparer comparer = StringComparer.InvariantCultureIgnoreCase;
44-
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));
44+
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));
4545

4646
if (cmd is null)
4747
{
@@ -95,7 +95,7 @@ await ctx.RespondAsync(
9595
}
9696

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

0 commit comments

Comments
 (0)