Skip to content

Commit c46daaa

Browse files
authored
fix: Add type reader when entity type reader exists (#1486)
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.
1 parent df23d57 commit c46daaa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Discord.Net.Commands/CommandService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ internal bool HasDefaultTypeReader(Type type)
408408
var typeInfo = type.GetTypeInfo();
409409
if (typeInfo.IsEnum)
410410
return true;
411-
return _entityTypeReaders.Any(x => type == x.EntityType || typeInfo.ImplementedInterfaces.Contains(x.TypeReaderType));
411+
return _entityTypeReaders.Any(x => type == x.EntityType || typeInfo.ImplementedInterfaces.Contains(x.EntityType));
412412
}
413413
internal void AddNullableTypeReader(Type valueType, TypeReader valueTypeReader)
414414
{
@@ -511,7 +511,7 @@ public async Task<IResult> ExecuteAsync(ICommandContext context, string input, I
511511
await _commandExecutedEvent.InvokeAsync(Optional.Create<CommandInfo>(), context, searchResult).ConfigureAwait(false);
512512
return searchResult;
513513
}
514-
514+
515515

516516
var commands = searchResult.Commands;
517517
var preconditionResults = new Dictionary<CommandMatch, PreconditionResult>();

0 commit comments

Comments
 (0)