From 54dd7ee973da54ea74ba312e3c2b9da921c9a2b9 Mon Sep 17 00:00:00 2001 From: Adam Gauthier Date: Sun, 19 Apr 2020 00:22:29 -0400 Subject: [PATCH] Fix add type reader for entity implementations When adding a type reader that replaces a default type reader, CommandService checks that it replaces a type in its default type readers or entity type readers (IMessage, IChannel, IRole, IUser). For entity types, it checks that the target type is the same as the entity type or it implements its type reader. Adding a type reader for a default type reader doesn't make much sense and the original intent was likely to check that the target type is or implements the entity type. --- src/Discord.Net.Commands/CommandService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index d5c060fe4..b65a6273d 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -408,7 +408,7 @@ namespace Discord.Commands var typeInfo = type.GetTypeInfo(); if (typeInfo.IsEnum) return true; - return _entityTypeReaders.Any(x => type == x.EntityType || typeInfo.ImplementedInterfaces.Contains(x.TypeReaderType)); + return _entityTypeReaders.Any(x => type == x.EntityType || typeInfo.ImplementedInterfaces.Contains(x.EntityType)); } internal void AddNullableTypeReader(Type valueType, TypeReader valueTypeReader) { @@ -511,7 +511,7 @@ namespace Discord.Commands await _commandExecutedEvent.InvokeAsync(Optional.Create(), context, searchResult).ConfigureAwait(false); return searchResult; } - + var commands = searchResult.Commands; var preconditionResults = new Dictionary();