Added Dynamic Enum TypeParsing, to support all enums
This commit is contained in:
@@ -75,19 +75,24 @@ namespace Discord.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
if (typeInfo.IsEnum)
|
||||
Module.Service.AddTypeReader(type, new EnumTypeReader(type));
|
||||
|
||||
var reader = Module.Service.GetTypeReader(type);
|
||||
|
||||
if (reader == null)
|
||||
{
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
if (typeInfo.IsEnum)
|
||||
{
|
||||
type = Enum.GetUnderlyingType(type);
|
||||
|
||||
reader = Module.Service.GetTypeReader(type);
|
||||
}
|
||||
reader = Module.Service.GetTypeReader(type);
|
||||
}
|
||||
|
||||
if (reader == null)
|
||||
throw new InvalidOperationException($"{type.FullName} is not supported as a command parameter, are you missing a TypeReader?");
|
||||
if (reader == null)
|
||||
throw new InvalidOperationException($"{type.FullName} is not supported as a command parameter, are you missing a TypeReader?");
|
||||
}
|
||||
|
||||
bool isUnparsed = parameter.GetCustomAttribute<UnparsedAttribute>() != null;
|
||||
if (isUnparsed)
|
||||
|
||||
Reference in New Issue
Block a user