danbot.js
v1.0.8
Published
Api wrap for Dan Bot-Hosting.
Downloads
2
Maintainers
Readme
danbot.js
A wrap for Dan Bot-Hosting.
- Discord: https://discord.gg/py4Nf4m
- Site: https://panel.danbot.host
Install
Node.js 12.0.0 or newer is required. As that is what discord.js requires.
NOTE: Discord is require to run module.
npm install danbot.js
How to get API Key
- Join our Discord (link)
- Go into our #bot-commands channel
- Type DBH!ApiKey and you'll get an API Key!
Examples
// import modules
const Discod = require('discord.js');
const danbotjs = require('danbot.js');
// Create instanceof client
const client = new Discod.Client();
// Log in the Client
client.login('Token');
// NOTE: It is important to login to discord
// before creating the host class
// Create your host class
const host = new danbotjs.Host(client, 'key');
// Client class ready event
client.on('ready', async () => {
console.log('ready');
// Await server bot info
const res = await host.info();
// post current info to server
await host.post();
// Log Server bot response
console.log(res);
});
/*
* NOTE: The events/methods arent limited to
* the clients "ready" event!
*/
// Host event emited on .post()
host.on('post', () => {
console.log('I have Posted');
});
client.on('message', (msg) => {
if (msg.content === 'post') {
host.post();
}
});
Docs
Events
- post
host.on('post', () => { // do something });
- autoPosting
host.on('autoPosting', () => { // do something });
- error
host.on('error', (error) => { // do something });
- stop
host.on('stop', () => { // do something });
- request
host.on('REQUEST', (response) => { // do something });
Classes
Host extends Base
new danbotjs.Host(client, key)
Paremeter: (client: Client, key: string)
autoPost(Time)
- Time?: number, optional,
Default:
60000
Amount of time betwen each post !must be 60000 or above!
,returns: Promise<void>
host.autoPost(80000);
autoStop()
returns: Promise<void>
host.autoStop();
Base extends EventEmitter
Paremeter: (Bot: Client or ShardingManager, key: string)
- post()
- returns: Promise<void>
host.post();
- info()
- returns: Promise<ServerInfo>
host.info();
- key
- returns: string
- This should be kept private at all times.
host.key;
- post()
Types
ServerInfo
Type: Object,
property:
- id: Snowflake - servers: string - users: string - owner: string - deleted: boolean - added: number - client: ClientUser
methods
- string: 'get', 'post', 'put', 'patch', 'delete'