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 pagesExample: 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:
path
string
β
Page identifier
component
string
β
Filename in pages/ (without extension)
title
string
β
Addon page tab title
Navigation
Open the addon from the dashboardβs Addons page. Its registered pages appear as tabs.
API Routes
Create custom backend endpoints:
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
Last updated