import static method

Future<BotFile> import({
  1. String fileName = 'PaperPlaneBot.json',
})

Import a PaperPlane file.

Implementation

static Future<BotFile> import({
  String fileName = 'PaperPlaneBot.json',
}) async {
  if (io.FileSystemEntity.typeSync(fileName) ==
      io.FileSystemEntityType.notFound) {
    throw PaperPlaneException(description: 'BotFile not found.');
  }

  final content = await io.File(fileName).readAsString();
  return BotFile._(
    Bot.fromJson(jsonDecode(content)),
    fileName: fileName,
  );
}