1.0.8 • Published 4 years ago

danbot.js v1.0.8

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

danbot.js

A wrap for Dan Bot-Hosting.

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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), optional, 
      
      Default: `60000`

      `Amount of time betwen each post !must be 60000 or above!`,

      returns: Promise<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>
  ```js
    host.autoPost(80000);
  ```


 * autoStop()
    
    returns: Promise<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>
```js
  host.autoStop();
```
  * post()
      - returns: Promise<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>
   ```js
    host.post();
   ```
  * info()
    - returns: Promise<[ServerInfo](#ServerInfo)>
  ```js
    host.info();
  ```

  * key
    - returns: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
    ```css
    - This should be kept private at all times.
    ```
  ```js
    host.key;
  ```

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'
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago