mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-13 10:48:26 -04:00
Using generic attributes for NadekoOptions now. Updated packages
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user