Using generic attributes for NadekoOptions now. Updated packages

This commit is contained in:
Kwoth
2023-01-21 02:21:08 +01:00
parent f0ac087fdb
commit affaaf2fab
26 changed files with 92 additions and 422 deletions

View File

@@ -86,7 +86,7 @@ public class HelpService : IExecNoCommand, INService
.WithFooter(GetText(strs.module(com.Module.GetTopLevelModule().Name), guild))
.WithOkColor();
var opt = ((NadekoOptionsAttribute)com.Attributes.FirstOrDefault(x => x is NadekoOptionsAttribute))?.OptionType;
var opt = GetNadekoOptionType(com.Attributes);
if (opt is not null)
{
var hs = GetCommandOptionHelp(opt);
@@ -97,6 +97,14 @@ public class HelpService : IExecNoCommand, INService
return em;
}
public static Type GetNadekoOptionType(IEnumerable<Attribute> attributes)
=> attributes
.Select(a => a.GetType())
.Where(a => a.IsGenericType
&& a.GetGenericTypeDefinition() == typeof(NadekoOptionsAttribute<>))
.Select(a => a.GenericTypeArguments[0])
.FirstOrDefault();
public static string GetCommandOptionHelp(Type opt)
{
var strs = GetCommandOptionHelpList(opt);