Creates a new JSONAdapter instance.
The path to the JSON file for storing giveaway data. Defaults to './giveaways.json' in the current working directory. The file will be created automatically if it doesn't exist.
Saves or updates giveaway data.
If a giveaway with the same ID already exists, it will be updated. Otherwise, a new giveaway will be added to the storage.
The giveaway data to save
Retrieves a specific giveaway by ID.
The unique giveaway ID to retrieve
The giveaway data or null if not found
Retrieves all giveaways from storage.
A copy of all giveaway data (to prevent external modification of cache)
Updates an existing giveaway with new data.
This implementation deletes the old giveaway and saves the new data, ensuring the giveaway ID can be changed if needed.
The current giveaway ID to update
The new giveaway data
File-based storage adapter using JSON format.
This adapter provides persistent storage for giveaway data using a local JSON file. It's ideal for simple deployments, development environments, or small bots where database setup might be overkill.
Features:
Example