User Data
This page explains how to work with Athena’s user data system.
User data
User data is commonly stored in the database and can be accessed from your plugin. For example, if you want to fetch a user’s data object, you can use the built-in model accessors and work with the returned document.
const model = this.heart.core.database.getModel('user').getModel();
const userData = await model.findOne({ userId: interaction.user.id });You can then update it or create a new record if it does not exist.
if (!userData) {
await model.create({ userId: interaction.user.id, balance: 0 });
}Always make sure your data structure matches the schema used by the relevant model.
Last updated