Skip to content
Functionutilsv0.9.0

readFiles

Reads every file under a directory, recursively and sorted by path, yielding its bytes. Text and binary files both work. It skips the code files importFiles imports, .map files, dotfiles, dot-folders and node_modules. In a built bot the files come from the build output. A relative dir resolves against root, the same as importFiles. Under seedcord dev and in a built bot, dir has to be one of the folders that files in seedcord.config.ts lists, or a subfolder of one.

Throws:

  • A SeedcordError when the directory or a file in it cannot be read.

  • A SeedcordError when dir is relative and the bot did not start through seedcord dev or its built output.

  • A SeedcordError when dir is outside every folder in files or has a dot-folder or node_modules in its path, under seedcord dev or in a built bot.

  • A SeedcordError when the directory was missing at build time, in a built bot.

readFiles(dir: string): AsyncGenerator<ReadFile>