getOptions method Null safety

Iterable<CommandOptionBuilder> getOptions(
  1. CommandsPlugin commands
)

Build the options for registering this group to the Discord API for slash commands.

Implementation

Iterable<CommandOptionBuilder> getOptions(CommandsPlugin commands) {
  List<CommandOptionBuilder> options = [];

  for (final child in children) {
    if (child.hasSlashCommand) {
      options.add(CommandOptionBuilder(
        CommandOptionType.subCommandGroup,
        child.name,
        child.description,
        options: List.of(child.getOptions(commands)),
      ));
    } else if (child is Command && child.type != CommandType.textOnly) {
      options.add(CommandOptionBuilder(
        CommandOptionType.subCommand,
        child.name,
        child.description,
        options: List.of(child.getOptions(commands)),
      ));
    }
  }

  return options;
}