1 | # miniplug
|
2 |
|
3 | Small [plug.dj][] client for building bots and applications in Node.js, with a Promise-based API.
|
4 |
|
5 | [Installation](#installation) -
|
6 | [Usage](#usage) -
|
7 | [API][docs/API.md] -
|
8 | [Status](#status) -
|
9 | [Contributing](#contributing) -
|
10 | [License: MIT](#license)
|
11 |
|
12 | ## Installation [![(install size)](https://packagephobia.now.sh/badge?p=miniplug)](https://packagephobia.now.sh/result?p=miniplug)
|
13 |
|
14 | > Note: Node v4 or higher is required.
|
15 | > Run `node -v` in your console to check that your Node.js version is up-to-date.
|
16 |
|
17 | ```sh
|
18 | npm install --save miniplug
|
19 | ```
|
20 |
|
21 | ## Usage
|
22 |
|
23 | ```js
|
24 | const miniplug = require('miniplug')
|
25 |
|
26 | const mp = miniplug()
|
27 |
|
28 | // Add an example chat command "!id"
|
29 | mp.on('chat', (message) => {
|
30 | if (/^!id/.test(message.message)) {
|
31 | message.reply(`Your user ID is ${message.uid}.`)
|
32 | }
|
33 | })
|
34 |
|
35 | // Connect to plug.dj
|
36 | mp.connect({
|
37 | email: 'admin@plug.dj',
|
38 | password: 'hunter2'
|
39 | }).catch((err) => {
|
40 | console.error('Could not connect to plug.dj:')
|
41 | console.error(err)
|
42 | process.exit(1)
|
43 | })
|
44 |
|
45 | // Join a room
|
46 | mp.join('tastycat').then(() => {
|
47 | const room = mp.room()
|
48 | mp.chat(`Hello ${room.name}! :wave:`)
|
49 | })
|
50 | ```
|
51 |
|
52 | ## API
|
53 |
|
54 | Full API documentation is available in [docs/API.md][].
|
55 |
|
56 | For questions, visit the #coding channel in the plug.dj discord!
|
57 |
|
58 | [![join the plug.dj discord](https://img.shields.io/badge/plug.dj-%23coding-7289DA.svg)](https://discord.gg/plugdj)
|
59 |
|
60 | ## Status
|
61 |
|
62 |
|
63 | [![Travis](https://img.shields.io/travis/miniplug/miniplug.svg)](https://travis-ci.org/miniplug/miniplug)
|
64 | [![npm version](https://img.shields.io/npm/v/miniplug.svg)](https://npmjs.com/package/miniplug)
|
65 | [![David](https://img.shields.io/david/miniplug/miniplug.svg)](https://david-dm.org/miniplug/miniplug)
|
66 | ![npm downloads](https://img.shields.io/npm/dt/miniplug.svg)
|
67 |
|
68 | ## Contributing
|
69 |
|
70 | Issues/PRs are appreciated!
|
71 |
|
72 | To build the library, run:
|
73 |
|
74 | ```bash
|
75 | npm run build
|
76 | ```
|
77 |
|
78 | The built version will be placed in `index.js`.
|
79 |
|
80 | To run tests, do:
|
81 |
|
82 | ```bash
|
83 | npm test
|
84 | ```
|
85 |
|
86 | There's not many tests just yet, but it's good to check anyway!
|
87 | This command will also check your code style using [Standard][].
|
88 |
|
89 | Changed files will also be tested and linted automatically when you `git commit`.
|
90 |
|
91 | ## License
|
92 |
|
93 | [![MIT](https://img.shields.io/npm/l/miniplug.svg)](./LICENSE)
|
94 |
|
95 | [plug.dj]: https://plug.dj
|
96 | [docs/API.md]: ./docs/API.md
|
97 | [Standard]: https://standardjs.com/
|