For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dashboard API

Extend the Drako Bot dashboard with custom pages and API endpoints.

✨ Features

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

  • Navigation Integration β€” Pages appear as tabs inside your addon

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

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

  • Authentication β€” Automatic auth handling for protected endpoints

πŸš€ 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

βœ…

Page identifier

component

string

βœ…

Filename in pages/ (without extension)

title

string

❌

Addon page tab title

Open the addon from the dashboard’s Addons page. Its registered pages appear as tabs.

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

❌

Additional Discord role IDs for API access

🎨 Styling Guide

Use your own CSS or inline React styles. Import a stylesheet from your page with import './styles.css'.

Use flexible widths so your page fits mobile screens.

πŸ”Œ API Endpoint Patterns

Accessing Your API

Page components receive an api prop. Call it with your route path to use the selected server and current dashboard session.

Making API Calls

Handler Examples

πŸ” Authentication & Permissions

Using requiredRoles

These addon pages require administrator access to every server the bot is in.

For API routes, 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

Enable Developer Mode in Discord:

  • Settings β†’ Advanced β†’ Developer Mode

  • 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 loaded from dashboard/config.js when the addon initializes. Restart the bot after changing dashboard code.

πŸ’‘ Tips & Best Practices

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

  • Handle loading states β€” Always show loading indicators

  • Error handling β€” Catch and display errors gracefully

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

  • 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
  • Import your addon stylesheet or use inline styles

  • 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