namespace VpSharp.Commands.Attributes.ExecutionChecks;
#pragma warning disable CA1019 // Define accessors for attribute arguments
///
/// Specifies that this command can only be run by bots.
///
public sealed class RequireAvatarNameAttribute : PreExecutionCheckAttribute
{
///
/// Initializes a new instance of the class.
///
/// An enumerable collection of allowed user names.
/// is .
public RequireAvatarNameAttribute(IEnumerable names)
{
ArgumentNullException.ThrowIfNull(names);
Names = names.ToArray();
}
///
/// Initializes a new instance of the class.
///
/// An array of allowed user names.
/// is .
[CLSCompliant(false)]
public RequireAvatarNameAttribute(params string[] names)
{
ArgumentNullException.ThrowIfNull(names);
Names = names[..];
}
///
/// Gets a read-only view of the user names allowed to run this command.
///
/// A of representing the allowed user names.
public IReadOnlyList Names { get; }
///
protected internal override Task PerformAsync(CommandContext context)
{
ArgumentNullException.ThrowIfNull(context);
return Task.FromResult(Names.Contains(context.Avatar.Name));
}
}