any static method

AbstractCheck any(
  1. Iterable<AbstractCheck> checks,
  2. [String? name]
)

Creates a check that succeeds if any of checks succeeds.

When this check is queried, each of checks is queried and if any are successful then this check is successful. If all of checks fail, then this check is failed.

Sometimes, developers might want to apply a check to all commands of a certain type. Instead of adding a check on each command of that type, nyxx_commands provides checks that will succeed when the context being checked is of a certain type:

For example, to only apply a check only to commands invoked from a message command:

commands.check(Check.any([
  InteractionCommandCheck(),
  Check((context) => context.user.username.contains('evrything')),
]));

commands.addCommand(ChatCommand(
  'test',
  'A test command',
  (IChatContext context) => context.respond(MessageBuilder.content('Hi there!')),
));

commands.onCommandError.listen((error) {
  if (error is CheckFailedException) {
    error.context.respond(MessageBuilder.content("Sorry, you can't use that command!"));
  }
});

Implementation

static AbstractCheck any(Iterable<AbstractCheck> checks, [String? name]) =>
    _AnyCheck(checks, name);