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) { if (names is null) { throw new ArgumentNullException(nameof(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) { if (names is null) { throw new ArgumentNullException(nameof(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) { if (context is null) { throw new ArgumentNullException(nameof(context)); } return Task.FromResult(Names.Contains(context.Avatar.Name)); } }