From 63fbdb394bc90595f2e9df6a7e387ede36662f18 Mon Sep 17 00:00:00 2001 From: RogueException Date: Mon, 27 Jun 2016 07:07:56 -0300 Subject: [PATCH] Ensure Task return type for commands --- src/Discord.Net.Commands/Command.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs index 53c4758d5..f9578d154 100644 --- a/src/Discord.Net.Commands/Command.cs +++ b/src/Discord.Net.Commands/Command.cs @@ -81,7 +81,7 @@ namespace Discord.Commands var reader = Module.Service.GetTypeReader(type); if (reader == null) - throw new InvalidOperationException($"This type ({type.FullName}) is not supported."); + throw new InvalidOperationException($"{type.FullName} is not supported as a command parameter, are you missing a TypeReader?"); bool isUnparsed = parameter.GetCustomAttribute() != null; if (isUnparsed) @@ -103,6 +103,9 @@ namespace Discord.Commands } private Func, Task> BuildAction(MethodInfo methodInfo) { + if (methodInfo.ReturnType != typeof(Task)) + throw new InvalidOperationException("Commands must return a non-generic Task."); + //TODO: Temporary reflection hack. Lets build an actual expression tree here. return (msg, args) => {