elliebot/src/Ellie.Bot.Common/Attributes/OnlyPublicBotAttribute.cs

21 lines
671 B
C#
Raw Normal View History

2023-07-15 22:25:21 +12:00
#nullable disable
using System.Diagnostics.CodeAnalysis;
namespace Ellie.Common;
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
[SuppressMessage("Style", "IDE0022:Use expression body for methods")]
public sealed class OnlyPublicBotAttribute : PreconditionAttribute
{
public override Task<PreconditionResult> CheckPermissionsAsync(
ICommandContext context,
CommandInfo command,
IServiceProvider services)
{
2023-07-15 22:37:02 +12:00
#if GLOBAL_ELLIE || DEBUG
2023-07-15 22:25:21 +12:00
return Task.FromResult(PreconditionResult.FromSuccess());
#else
return Task.FromResult(PreconditionResult.FromError("Only available on the public bot."));
#endif
}
}