dbd.express
v1.0.1
Published
DBD.JS - Dashboard Package
Downloads
27
Readme
DBD.JS Express
A Website Package dependent for DBD.JS Dashboard
Example Usage
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"
})
Methods
Package
- Package( DBDJSClient ) - The constructor of Package
Constrcutor
- < Package Constrcutor >.API({ API Options }) - A method to create the API for people to be able to Access the Bot from any Website (Dashboard Purpose)
- < Package Constrcutor >.UI() - A method to create a UI, allow people to be able to modify from Website with Accounts
NOTE
- Adding Accounts can be seen in documentation
- Added an extra property
Express
inclient
of $djsEval andBot.client
Options
API
- 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 Activity
Access 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
headers:{
'Authorization': "Bearer root@1234",
'Content-Type': "application/json
}
API Methods
We only accept JSON for POST, PATCH, DELETE Request
GET
- /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
POST
- /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:
body:JSON.stringify({
command:{
name:"ping",
callback:"command",
code:"Pong!"
}
})
Response:
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:
body:JSON.stringify({
variables:{
money:0,
bank:0,
myname:"Matthew"
}
})
Response:
status:"SAVED",
received_body:{
variables:{
money:0,
bank:0,
myname:"Matthew"
}
}
PATCH / UPDATE
- /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:
{
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:
body:JSON.stringify({
target:{
id:"12345"
},
update:{
name:"ping",
callback:"command",
code:`Pong! My Ping is $botPing Miliseconds`
}
})
Response:
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
DELETE
- /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:
body:JSON.stringify({
target:{
ID:"ID of Command (Number)"
}
})
Response:
status:"DELETED",
received_body:{
target:{
ID:"12345"
}
}
- /api/restart - Restart the API and Client Required: None Response:
{
message:"ACCEPTED, SHUTDOWN IN 3 SECONDS"
}
Programmatic
You can access with client.Express
in $djsEval or Bot.client
Available Options
- addAccounts(data) - Add accounts for UI
- updateAccount(target (ID of an Account), newData, callback) - Edit an Account to the new Data
- deleteAccount(target (ID of an Account), callback) - Deletes an Account
- addCommands(data) - Add commands to Bot
- loadBotCommands() - Load all bot Commands to store in Database, later use for UI
- editCommand(target (ID of command), newData, callback) - Edit a Command
- deleteCommand(target (ID of command), callback) - Delete a command
- restartProject() - Restarts the Project after 3 seconds
- Variables - Return Bot Variables
- Commands - Return Bot Commands
- ACCOUNTS - Return an array of UI Accounts
- refreshBotCommands() - Reload UI Commands