mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
.crypto will now show CoinMarketCap rank. Small refactor
This commit is contained in:
@@ -11,33 +11,4 @@ public abstract class NadekoTypeReader<T> : TypeReader
|
||||
string input,
|
||||
IServiceProvider services)
|
||||
=> await ReadAsync(ctx, input);
|
||||
}
|
||||
|
||||
public static class TypeReaderResult
|
||||
{
|
||||
public static TypeReaderResult<T> FromError<T>(CommandError error, string reason)
|
||||
=> Discord.Commands.TypeReaderResult.FromError(error, reason);
|
||||
|
||||
public static TypeReaderResult<T> FromSuccess<T>(in T value)
|
||||
=> Discord.Commands.TypeReaderResult.FromSuccess(value);
|
||||
}
|
||||
|
||||
public readonly struct TypeReaderResult<T>
|
||||
{
|
||||
public bool IsSuccess
|
||||
=> _result.IsSuccess;
|
||||
|
||||
public IReadOnlyCollection<TypeReaderValue> Values
|
||||
=> _result.Values;
|
||||
|
||||
private readonly Discord.Commands.TypeReaderResult _result;
|
||||
|
||||
private TypeReaderResult(in Discord.Commands.TypeReaderResult result)
|
||||
=> _result = result;
|
||||
|
||||
public static implicit operator TypeReaderResult<T>(in Discord.Commands.TypeReaderResult result)
|
||||
=> new(result);
|
||||
|
||||
public static implicit operator Discord.Commands.TypeReaderResult(in TypeReaderResult<T> wrapper)
|
||||
=> wrapper._result;
|
||||
}
|
30
src/NadekoBot/Common/TypeReaders/TypeReaderResult.cs
Normal file
30
src/NadekoBot/Common/TypeReaders/TypeReaderResult.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public readonly struct TypeReaderResult<T>
|
||||
{
|
||||
public bool IsSuccess
|
||||
=> _result.IsSuccess;
|
||||
|
||||
public IReadOnlyCollection<TypeReaderValue> Values
|
||||
=> _result.Values;
|
||||
|
||||
private readonly Discord.Commands.TypeReaderResult _result;
|
||||
|
||||
private TypeReaderResult(in Discord.Commands.TypeReaderResult result)
|
||||
=> _result = result;
|
||||
|
||||
public static implicit operator TypeReaderResult<T>(in Discord.Commands.TypeReaderResult result)
|
||||
=> new(result);
|
||||
|
||||
public static implicit operator Discord.Commands.TypeReaderResult(in TypeReaderResult<T> wrapper)
|
||||
=> wrapper._result;
|
||||
}
|
||||
|
||||
public static class TypeReaderResult
|
||||
{
|
||||
public static TypeReaderResult<T> FromError<T>(CommandError error, string reason)
|
||||
=> Discord.Commands.TypeReaderResult.FromError(error, reason);
|
||||
|
||||
public static TypeReaderResult<T> FromSuccess<T>(in T value)
|
||||
=> Discord.Commands.TypeReaderResult.FromSuccess(value);
|
||||
}
|
Reference in New Issue
Block a user