Skip to content

Class: Data ​

Data is a simple utility class for the management of plugin data. An instance is available on BdApi.

Methods ​

delete() ​

delete(pluginName, key): void

Deletes a piece of stored data. This is different than saving null or undefined.

Parameters ​

ParameterTypeDescription
pluginNamestringName of the plugin deleting data
keystringWhich piece of data to delete.

Returns ​

void


load() ​

load(pluginName, key): unknown

Loads previously stored data.

Parameters ​

ParameterTypeDescription
pluginNamestringName of the plugin loading data
keystringWhich piece of data to load

Returns ​

unknown

The stored data


recache() ​

recache(pluginName): Promise<boolean>

Recaches JSON-serializable save file.

Parameters ​

ParameterTypeDescription
pluginNamestringName of the plugin saving data

Returns ​

Promise<boolean>

Whether the data successfully recached

⚠️ Use of recaching is discouraged!

Recache loads can block the filesystem and significantly degrade performance. Use this method only for debugging or testing purposes. Avoid frequent recaching in production environments.


save() ​

save(pluginName, key, data): void

Saves JSON-serializable data.

Parameters ​

ParameterTypeDescription
pluginNamestringName of the plugin saving data
keystringWhich piece of data to store
dataanyThe data to be saved

Returns ​

void