Browse Source

Fallback on the default value on a failed read

pull/1488/head
Joe4evr 5 years ago
parent
commit
57cf5fe2b9
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      src/Discord.Net.Commands/Info/ParameterInfo.cs

+ 4
- 1
src/Discord.Net.Commands/Info/ParameterInfo.cs View File

@@ -90,7 +90,10 @@ namespace Discord.Commands
public async Task<TypeReaderResult> ParseAsync(ICommandContext context, string input, IServiceProvider services = null)
{
services = services ?? EmptyServiceProvider.Instance;
return await _reader.ReadAsync(context, input, services).ConfigureAwait(false);
var readerResult = await _reader.ReadAsync(context, input, services).ConfigureAwait(false);
return (!readerResult.IsSuccess && IsOptional)
? TypeReaderResult.FromSuccess(DefaultValue)
: readerResult;
}

public override string ToString() => Name;


Loading…
Cancel
Save