Skip to content
On this page

Settings Handler

A quick and easy way to store and retrieve settings from your dashboard.

Setup

Add these lines to your code to initialize the Storage Handler.

js
(async () => {
    await DBD.useLicense(config.dbd.license);
    DBD.Dashboard = DBD.UpdatedClass();

    const Handler = new DBD.Handler( 
    /*
            Keyv storage instance
            Example: { store: new KeyvMongo('mongodb://user:pass@localhost:27017/dbname') }

            Can be left empty to use the default storage (Keyv with SQLite)
        */
    ); 

    const { Category, Option } = Handler; 
});
ArgumentType
KeyvKeyv Storage Objecthttps://www.npmjs.com/package/keyv

Configuring Settings

js
settings: [
    new Category()
        .setId('setup') // Sets the id of the category - must be unique
        .setName("Setup") // Name of the category
        .setDescription("Setup your bot with default settings!") // Description of the category
        .setToggleable(true) // Sets the category to be toggleable
        .setImage("https://assistantscenter.com/api/user/avatar/63ad65e2d3f1b1b3acdff794")
        .addOptions(
            new Option() // Creates a new option inside the category
                .setId('lang') // Sets the id of the option - must be unique
                .setName("Language Select") // Name of the option
                .setDescription("Change bot's language easily") // Description of the option
                .setType(DBD.formTypes.select({ "Polish": 'pl', "English": 'en', "French": 'fr' })), // The DBD form type function

            new Option()
                .setId('message')
                .setName("Join Message")
                .setDescription("Is the join message enabled?")
                .setType(DBD.formTypes.switch(false))
        )
]

Fetching Data

js
const data = await Handler.fetch('guildID', 'optionID');
ArgumentType
guildIDStringThe guild you want to fetch the data from
optionIDStringThe option ID you want the value for

Released under the MIT License.