DBD.JS - Dashboard Package
npm install dbd.express
``js
const dbdExpress = require("dbd.express")
const dbdjs = require("dbd.js")
const bot = new dbdjs.Bot({
//Options
})
const Dashboard = new dbdExpress(bot)
Dashboard.API({
port:3000,
useSecureProtocol:true,
authorizationKey:"Bearer root@1234"
})
`
in client of $djsEval and Bot.clientOptions
$3
- port [ Number ] - The port for Express to Listen
- useSecureProtocol [ Boolean ] - An option for Request to be redirected to https if request is using http
- authorizationKey [ String ] - A key that should be provided in Request Headers before Accessed the API
- debug [ Boolean ] - A mode to get API ActivityAccess the API
You will need to provide a Header Authorization Key to access the API and also Content-Type as application/json to Send Body
`js
headers:{
'Authorization': "Bearer root@1234",
'Content-Type': "application/json
}
`API Methods
###### We only accept JSON for POST, PATCH, DELETE Request
$3
- /api/client - Returns a Discord Client
- /api/commands - Returns an Array of Client Commands
- /api/variables - Returns an Array of Client Variables
- /api/accounts = Returns an Array of Created Accounts$3
- /api/commands - Send a POST Request with body to make a new Command
Required:
- Body - The Body of Request
- Body.command - The Command Data (typeof data == object)
Example Request:
`js
body:JSON.stringify({
command:{
name:"ping",
callback:"command",
code:"Pong!"
}
})
`
Response:
`js
status:"SAVED",
received_body:{
command:{
name:"ping",
code:"Pong!"
}
}
`
- /api/variables - Send a POST Request with body to modify Variables
Required:
- Body - The Body of Request
- Body.variables - The Variables data (typeof data == object)
Example Request:
`js
body:JSON.stringify({
variables:{
money:0,
bank:0,
myname:"Matthew"
}
})
`
Response:
`js
status:"SAVED",
received_body:{
variables:{
money:0,
bank:0,
myname:"Matthew"
}
}
`$3
- /api/commands - Send a PATCH Request with body to modify a command
Required:
- Body - The Body of Request
- Body.target - Command Target that will be modified (typeof data == object)
Example Body.target:
`js
{
id:"ID of Command (Number)"
}
`
###### TARGET DATA MUST BE EXACTLY AS THE COMMAND THAT EXIST IN CLIENT COMMANDS
- Body.update - The Command data that will modify Targetted Command (typeof data == object)
Example Request:
`js
body:JSON.stringify({
target:{
id:"12345"
},
update:{
name:"ping",
callback:"command",
code:Pong! My Ping is $botPing Miliseconds
}
})
`
Response:
`js
status:"UPDATED",
received_body:{
target:{
id:"12345"
},
update:{
name:"ping",
callback:"command",
code:Pong! My Ping is $botPing Miliseconds
}
},
target:{command} // Found command by ID
`
$3
- /api/commands - Send a DELETE Request with Body to delete an existing command
Required:
- Body - The Body of Request
- Body.target - The Target to delete the Command
###### TARGET DATA MUST BE EXACTLY AS THE COMMAND THAT EXIST IN CLIENT COMMANDS
Example Request:
`js
body:JSON.stringify({
target:{
ID:"ID of Command (Number)"
}
})
`
Response:
`js
status:"DELETED",
received_body:{
target:{
ID:"12345"
}
}
`
- /api/restart - Restart the API and Client
Required: None
Response:
`js
{
message:"ACCEPTED, SHUTDOWN IN 3 SECONDS"
}
`
Programmatic
You can access with client.Express` in $djsEval or Bot.client