From 63fdd67413b9a7bb5284663c99e3f673d9de5659 Mon Sep 17 00:00:00 2001 From: Khionu Terabite Date: Wed, 20 Jul 2016 15:17:22 -0400 Subject: [PATCH] Initial Plan for allowing custom Enum Type Readers --- src/Discord.Net.Commands/Command.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs index f9578d154..9b89b2cc0 100644 --- a/src/Discord.Net.Commands/Command.cs +++ b/src/Discord.Net.Commands/Command.cs @@ -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?");