A generic library to create plug.dj bots.
const PlugApi = require('plug-dj-api');
const plugApi = new PlugApi();
const options = {
roomId: '',
username: '',
password: '',
};
(async () => {
try {
// Login and visit room
await plugApi.connect(options);
console.log(`Connected to room: ${options.roomId}`);
// Handle CHAT events
plugApi.on('CHAT', data => {
console.log(data);
});
// Handle song ADVANCE
plugApi.on('ADVANCE', data => {
plugApi.sendChat('Song transitioned!');
});
} catch (err) {
console.log(`Error setting up api: ${err}`);
}
})();
Follow these steps to run the provided sample bot:
- Install dependencies
$ npm install
- Build the project
$ npm run build
- Configure your bot credentials
// Copy sample config and edit credentials within
$ cp example/config.sample.json example/config.json
- Run it
$ node example/bot.js