Browse Source

Initial Plan for allowing custom Enum Type Readers

pull/140/head
Khionu Terabite 9 years ago
parent
commit
63fdd67413
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      src/Discord.Net.Commands/Command.cs

+ 10
- 4
src/Discord.Net.Commands/Command.cs View File

@@ -75,11 +75,17 @@ namespace Discord.Commands
continue;
}

var typeInfo = type.GetTypeInfo();
if (typeInfo.IsEnum)
type = Enum.GetUnderlyingType(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);
}

if (reader == null)
throw new InvalidOperationException($"{type.FullName} is not supported as a command parameter, are you missing a TypeReader?");



Loading…
Cancel
Save