namespace VpSharp.Commands.Attributes.ExecutionChecks;
///
/// Specifies that this command can only be run by bots.
///
public sealed class RequireUserIdAttribute : PreExecutionCheckAttribute
{
///
/// Initializes a new instance of the class.
///
/// An array of allowed user IDs.
/// is .
public RequireUserIdAttribute(params int[] userIds)
{
ArgumentNullException.ThrowIfNull(userIds);
UserIds = userIds[..];
}
///
/// Gets a read-only view of the user IDs allowed to run this command.
///
/// A of representing the allowed user IDs.
public IReadOnlyList UserIds { get; }
///
protected internal override Task PerformAsync(CommandContext context)
{
ArgumentNullException.ThrowIfNull(context);
return Task.FromResult(UserIds.Contains(context.Avatar.User.Id));
}
}