Help part 2

This commit is contained in:
Karolis2011
2019-06-20 01:01:49 +03:00
parent b5702faa31
commit 18657d7fab
3 changed files with 62 additions and 4 deletions

View File

@@ -26,7 +26,22 @@ namespace EventBot.Misc
public static string FormatCallHelpString(this CommandInfo command)
{
return $"{command.Aliases[0]} {string.Join(" ", command.Parameters.Select(p => p.IsOptional ? $"[{p.Name}]" : $"<{p.Name}>"))}";
return $"{command.Aliases[0]} {string.Join(" ", command.Parameters.Select(p => p.FormatParameter()))}";
}
public static string FormatParameter(this ParameterInfo p) => p.IsOptional ? $"[{p.Name}]" : $"<{p.Name}>";
public static string FormatParameterType(this ParameterInfo p)
{
var @switch = new Dictionary<Type, Func<ParameterInfo, string>>()
{
{ typeof(int), (_) => "Number" },
};
if (@switch.ContainsKey(p.Type))
return @switch[p.Type](p);
else
return p.Type.Name;
}
}
}