mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-13 18:58:27 -04:00
Gambling moved to a separate project. Project builds
This commit is contained in:
30
src/Nadeko.Bot.Common/TypeReaderResult.cs
Normal file
30
src/Nadeko.Bot.Common/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