Databases
Video Tutorial
This video tutorial goes over how to save data using databases in inventor.
Written Tutorial
Database Management Tutorial
This tutorial will guide you through creating a database, looking up user points, and updating points in the database using flows. Follow these steps to build and test your setup.
1. Create a New Database
Access the Database Section
On your dashboard sidebar, find and click on the Database tab.
×
\
Create a Database
In the top-right corner, click the New Database button (gray).
×\
Name the database points and click Create Database.
×
Add Columns
- You’ll be redirected to the database editor. Here, add the following columns:
- user_id
- points×
- You’ll be redirected to the database editor. Here, add the following columns:
Your database is now ready.
2. Looking Up Values in the Database
Create a Flow
Create a new flow and name it Lookup User Points.
Set the trigger to Slash Command.
Name the command lookup-points.
×
\
Add a Lookup by Value or Create Block
- Add this block to the flow and configure it as follows:
Select the points database from the dropdown.
Select the user_id collumn from the dropdown.
Set the Value field to the user ID of the executing user.
×
\
- Add this block to the flow and configure it as follows:
Add a Text Reply to Interaction Block
Add this block and write the message:
- The user has
{points}
points.
- The user has
Use the points variable from the Lookup block to display the
{points}
value.×
\
Test the Command
- Run
/lookup-points
in Discord. The bot should respond with:The user has points.
×
If no points are saved yet, the response may show a blank value. Don’t worry, this will be updated in the next step.- Run
3. Editing the Database with a Flow
Create a Flow
Create a new flow and name it Add Points to User.
Set the trigger to Slash Command.
Name the command add-point.
×
\
Add a Lookup by Value or Create Block
- Add this block to the flow and configure it as follows:
Select the points database from the dropdown.
Select the user_id collumn from the dropdown.
Set the Value field to the user ID of the executing user.
×
\
- Add this block to the flow and configure it as follows:
Add a Math Operations Block
- Add this block and configure it to increment the points:
Value 1: Use the
points
value from the Lookup block.Operation: Addition.
Value 2: Set this to
1
.×
\
- Add this block and configure it to increment the points:
Add an Update Row Block
- Add this block and configure it as follows:
Select the points database.
Row ID: Use the row ID from the Lookup block.
Keep Value if Blank: Turn this option on.
Set the points field to the result of the Math Operations block.
×
\
- Add this block and configure it as follows:
Add a Text Reply to Interaction Block
- Add this block and write:
Added one point.
×
\
- Add this block and write:
Test the Command
Run
/add-point
in Discord. The bot should respond with:Added one point.
×
\
Use
/lookup-points
to verify the update. The bot should now respond with:The user has 1 points.
×\
Now your bot can track and update points for users with simple commands! Use this setup to build more features that interact with your database.