elliebot/src/EllieBot/_common/IPermissionChecker.cs

37 lines
804 B
C#
Raw Normal View History

using OneOf;
namespace EllieBot.Common;
public interface IPermissionChecker
{
Task<PermCheckResult> CheckPermsAsync(IGuild guild,
IMessageChannel channel,
IUser author,
string module,
string? cmd);
}
[GenerateOneOf]
public partial class PermCheckResult
: OneOfBase<PermAllowed, PermCooldown, PermGlobalBlock, PermDisallowed>
{
public bool IsAllowed
=> IsT0;
2024-06-26 00:44:07 -07:00
public bool IsCooldown
=> IsT1;
2024-06-26 00:44:07 -07:00
public bool IsGlobalBlock
=> IsT2;
2024-06-26 00:44:07 -07:00
public bool IsDisallowed
=> IsT3;
}
public readonly record struct PermAllowed;
public readonly record struct PermCooldown;
public readonly record struct PermGlobalBlock;
public readonly record struct PermDisallowed(int PermIndex, string PermText, bool IsVerbose);