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

  1. Access the Database Section

    • On your dashboard sidebar, find and click on the Database tab.

    \

  2. Create a Database

    • In the top-right corner, click the New Database button (gray).


      \

    • Name the database points and click Create Database.

  3. Add Columns

    • You’ll be redirected to the database editor. Here, add the following columns:
      • user_id
      • points

Your database is now ready.


2. Looking Up Values in the Database

  1. Create a Flow

    • Create a new flow and name it Lookup User Points.

    • Set the trigger to Slash Command.

    • Name the command lookup-points.


    \

  2. 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.


    \

  3. Add a Text Reply to Interaction Block

    • Add this block and write the message:

      • The user has {points} points.
    • Use the points variable from the Lookup block to display the {points} value.


    \

  4. 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.


3. Editing the Database with a Flow

  1. 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.


    \

  2. 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.


    \

  3. 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.


    \

  4. 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.


    \

  5. Add a Text Reply to Interaction Block

    • Add this block and write:
      • Added one point.


    \

  6. 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.