Skip to content
BooleanCube edited this page Apr 5, 2023 · 9 revisions

DiscordDB (JDA Database Library)

Welcome to the DiscordDB wiki! Here, you can make your discord bot development process 10x times easier with simpler to use database libraries.

Examples

class CurrencyDatabase {
    
    private static DatabaseObject currency;

    public static void setupDatabases() {
        try {
            DatabaseManager.createDatabase("currency");
            DatabaseObject currency = DatabaseManager.getDatabase("currency");
        } catch (LimitExceededException | FileAlreadyExistsException | FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public static int getUserBalance(String id) {
        if(currency.getValue(id) == null) {
            currency.addKey(id, "0");
            return 0;
        }
        return currency.getValueInt(id);
    }

    public static void addToUserBalance(String id, int increment) {
        int balance = getUserBalance(id) + increment;
        currency.updateValue(id, String.valueOf(Math.max(0, balance)));
    }

}
public class UsageExample {

    public static void main(String[] args) {

        CurrencyDatabase.setupDatabases();

        String boolId = "525126007330570259";
        int boolBalance = CurrencyDatabase.getUserBalance(boolId);
        System.out.println("This is bool's current balance: " + boolBalance);

        CurrencyDatabase.addToUserBalance(boolId, 100);
        boolBalance = CurrencyDatabase.getUserBalance(boolId);
        System.out.println("This is bool's new balance: " + boolBalance);

    }

}

To get more examples, visit the examples directory

Documentation

To get the documentation for the latest stable version of DiscordDB, go to the documentation page.

Note however, that this will only contain the documentation for the latest stable version.
To get the documentation for previous stable builds as well click on the link in the documentation wiki page.

Installation

The easiest and most recommended way to install the DiscordDB library is to use JitPack or maven-central via maven or gradle rather than manually downloading the source code. All the instructions towards the installation of DiscordDB is in the installation manual.

Help

If you ran into trouble while using the DiscordDB library and are looking for help. Take a look in the issues page to see if there are others with similar bugs. If not, create a new issue to notify the developers or contributors of this issue.

If there is a small misunderstanding of a concept or topic, you can contact the developers, experts, or myself (bool#4690) via discord

Pages

Clone this wiki locally