# readFiles

`function` in `utils` · v0.9.0

<https://seedcord.org/docs/packages/utils/0.9.0/functions/read-files>

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`](/docs/packages/utils/0.9.0/functions/import-files) 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`](/docs/packages/utils/0.9.0/functions/import-files).
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.

```ts
readFiles(dir: string): AsyncGenerator<ReadFile>
```

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`](/docs/packages/utils/0.9.0/functions/import-files) 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`](/docs/packages/utils/0.9.0/functions/import-files).
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.

Parameters.

- `dir` `string`

Returns `AsyncGenerator<ReadFile>`.
