resolvedOptions property

  1. @override
CommandOptions resolvedOptions
inherited

Get the resolved options for this child.

Since CommandRegisterable implements Options, any class implementing this interface can provide options. However, since options are designed to be inherited, this getter provides a quick way to access options merged with those of this child's parent, if any.

You might also be interested in:

  • options, for getting the options unique to this child.

Implementation

@override
CommandOptions get resolvedOptions {
  if (parent == null) {
    return options;
  }

  CommandOptions parentOptions = parent is CommandRegisterable
      ? (parent as CommandRegisterable).resolvedOptions
      : parent!.options;

  CommandType? parentType = parentOptions.type;
  if (parent is CommandsPlugin) {
    if ((parent as CommandsPlugin).prefix == null && parentType == CommandType.all) {
      parentType = CommandType.slashOnly;
    }
  }

  return CommandOptions(
    autoAcknowledgeInteractions:
        options.autoAcknowledgeInteractions ?? parentOptions.autoAcknowledgeInteractions,
    acceptBotCommands: options.acceptBotCommands ?? parentOptions.acceptBotCommands,
    acceptSelfCommands: options.acceptSelfCommands ?? parentOptions.acceptSelfCommands,
    defaultResponseLevel: options.defaultResponseLevel ?? parentOptions.defaultResponseLevel,
    type: options.type ?? parentType,
    autoAcknowledgeDuration:
        options.autoAcknowledgeDuration ?? parentOptions.autoAcknowledgeDuration,
    caseInsensitiveCommands:
        options.caseInsensitiveCommands ?? parentOptions.caseInsensitiveCommands,
  );
}