fix(IsLoadableModule): return false for abstract classes (#3148)
* fix(IsLoadableModule): return false for abstract classes IsLoadableModule did not check the property TypeInfo.IsAbstract. Therefore, an unnecessary warning log stated that it could not be loaded. Now, if a class is abstract, it will be ignored safely and all the inheritors will continue to load any commands. * fix: handle other attributes Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> * refactor: simplify attribute logic * fix: correct terminology in debug message --------- Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
This commit is contained in:
@@ -13,9 +13,9 @@ namespace Discord.Commands
|
||||
|
||||
public static async Task<IReadOnlyList<TypeInfo>> SearchAsync(Assembly assembly, CommandService service)
|
||||
{
|
||||
bool IsLoadableModule(TypeInfo info)
|
||||
static bool IsLoadableModule(TypeInfo info)
|
||||
{
|
||||
return info.DeclaredMethods.Any(x => x.GetCustomAttribute<CommandAttribute>() != null) &&
|
||||
return !info.IsAbstract && info.DeclaredMethods.Any(x => x.GetCustomAttribute<CommandAttribute>() != null) &&
|
||||
info.GetCustomAttribute<DontAutoLoadAttribute>() == null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user