Dashboard API

Extend the DrakoBot dashboard with custom pages, navigation items, and API endpoints.


✨ Features

  • Custom Pages β€” Add your own React pages to the dashboard

  • Navigation Integration β€” Seamlessly add items to the sidebar

  • API Routes β€” Create custom backend endpoints for your addon

  • Full React Support β€” Use hooks, state, and all React features

  • Tailwind CSS β€” Style with the dashboard's existing design system

  • Authentication β€” Automatic auth handling for protected endpoints

  • Hot Reload β€” Changes reflect instantly during development


πŸš€ Quick Start

Folder Structure

addons/
└── my-addon/
    β”œβ”€β”€ my-addon.js          # Main addon file (events, etc.)
    └── dashboard/
        β”œβ”€β”€ config.js         # Dashboard configuration
        └── pages/
            β”œβ”€β”€ index.jsx     # Main page component
            └── settings.jsx  # Additional pages

Example: Complete Dashboard Addon

addons/my-addon/dashboard/config.js

addons/my-addon/dashboard/pages/index.jsx


πŸ“„ Configuration Reference

Pages

Register custom pages in your addon:

Property
Type
Required
Description

path

string

βœ…

URL path for the page

component

string

βœ…

Filename in pages/ (without extension)

title

string

❌

Browser tab title

requiredRoles

string[]|null

❌

Discord role IDs required to access

Add items to the dashboard sidebar:

Property
Type
Required
Description

name

string

βœ…

Display name in sidebar

path

string

βœ…

Navigation destination

emoji

string

❌

Emoji to display

icon

string

❌

FontAwesome icon name

requiredRoles

string[]|null

❌

Discord role IDs required to see item

order

number

❌

Sort priority (lower = higher)

API Routes

Create custom backend endpoints:

Property
Type
Required
Description

method

string

βœ…

get, post, put, delete, patch

path

string

βœ…

Endpoint path (prefixed with /api/addons/{addonname})

handler

function

βœ…

Express route handler

middleware

array

❌

Additional middleware functions

requiredRoles

string[]|null

❌

Discord role IDs required to access


🎨 Styling Guide

Available CSS Classes

The dashboard uses Tailwind CSS with custom utility classes:

Responsive Design


πŸ”Œ API Endpoint Patterns

Accessing Your API

Your API routes are available at:

Example:

  • Addon name: MyAddon

  • Route path: /stats

  • Full URL: /api/addons/myaddon/stats

Making API Calls

Handler Examples


πŸ” Authentication & Permissions

Using requiredRoles

The requiredRoles property accepts an array of Discord role IDs. Users must have at least one of the specified roles to access the resource.

Complete Example with Permissions

Getting Role IDs

1

Enable Developer Mode in Discord:

  • Settings β†’ Advanced β†’ Developer Mode

2

Copy the role ID:

  • Right-click the role β†’ Copy Role ID

Checking User in API Handler


🧩 Complete Examples

Stats Dashboard

Settings Panel


πŸ“‹ Requirements Summary

Minimum Required

config.js Template

Page Component Template


πŸ”„ Integration with Event API

Combine dashboard with event handlers:

addons/my-addon/my-addon.js

The dashboard config is automatically loaded from dashboard/config.js when the addon initializes.


πŸ’‘ Tips & Best Practices

1

Use meaningful addon names β€” The addon name becomes part of the API URL

2

Handle loading states β€” Always show loading indicators

3

Error handling β€” Catch and display errors gracefully

4

API validation β€” Always validate request data on the backend

5

Permission checks β€” Use permissions for sensitive features


Troubleshooting

Page not loading
  • Check browser console for errors

  • Verify file exists in dashboard/pages/

  • Ensure component has export default

API returns 404
  • Check addon name is lowercase in URL

  • Verify route is registered in config.js

  • Check server logs for registration messages

Styles not applying
  • Use existing Tailwind classes

  • Check class names are correct

  • Verify you're using the right CSS variable names

Authentication issues
  • Ensure you're logged into the dashboard

  • Check if route requires specific permissions

  • Verify session is active


Last updated