Discord-Dashboard Tutorial #2.2: Creating Custom Options

In this section, we will focus on describing for you how to create custom options in the dashboard and how they work.

How do I create my own option

Discord-Dashboard allows you to create a two-tier system of options because you can divide them into categories. Therefore, all you need to do in the config Dashboard is to place a category object in the Array and Option objects for that option category in the Array.

What does Category Object looks like

{
    categoryId: 'unique_id',
    categoryName: "Category Name",
    categoryDescription: "Category Description",
    categoryOptionsList: [
        categoryOptionObject,
        categoryOptionObject,
		...
    ]
}
OptionType
categoryIdStringCategory ID (must be lowercase and unique).
categoryNameStringCategory name. Can include HTML code.
categoryDescriptionStringCategory description. Can include HTML code.
categoryOptionsListArrayAn Array of the categoryOptionObject Objects.

What does Category Option Object looks like

{
    /* Required options */
    optionId: 'unique_id',
    optionName: "Option Name",
    optionDescription: "Option Description",
    optionType: <DBDFormType>,
    getActualSet: async ({guild,user}) => {
        return <DBDFormTypeValueType>;
    },
    setNew: async ({guild,user,newData}) => {
        return <DBDFormTypeValueType>;
    },
    /* Optional options */
    allowedCheck: async ({guild,user}) => {
        if(guild.id == "123456789876")return {allowed: false, errorMessage: 'You cannot use this option - guild is blacklisted for it.'};
        if(user.id == "123456789876")return {allowed: false, errorMessage: 'You cannot use this option - user is blacklisted for.'};
        return {allowed: true, errorMessage: null};
    }
}
OptionType
optionIdStringOption ID (must be lowercase and unique).
optionNameStringOption name. Can include HTML code.
optionDescriptionStringOption description. Can include HTML code.
optionTypeObject (DBD Form Type)DBD Option Type. FormTypes are listed in this section of the tutorial.
getActualSetasync FunctionThe function for which you should return the currently set value for the option. The function passes you a user and a guild Object.
setNewasync FunctionA function that the Dashboard performs whenever a user changes the settings of an option. It passes you the userguild, and newData Objects.
allowedCheck (optional)async FunctionA function that checks if the option should be enabled to be changed by the user on the guild. It passes you the user and guild Objects.

What are getActualSet and setNew functions

Both of these functions serve the most important purpose of the dashboard – passing current data and saving new data to the database.
For example, if a user enters a page, you need to display the currently set prefix to them, right? That’s what the getActualSet function is for.
Conversely, if the user saves a new prefix, you need to set it. That’s what the setNew function does.

What are the FormTypes

If you want to create the ability to change the prefix for the user, you would use a text input with a character limit of 4, right? With Discord-Dashboard this is trivially easy because you just need to choose the right input type and give it settings like minimum and maximum character length, which is also trivially easy. And that’s what FormTypes are.

What FormTypes are available

There are quite a few FormTypes available, however, we are still updating their database to be richer. It will get even bigger for the upcoming Soft-UI Theme!
Let’s introduce you to all the available ones!

Please head to the next tutorial part.

Table of Contents