1.0.4 • Published 3 years ago

@vnbot/toolkit v1.0.4

Weekly downloads
182
License
ISC
Repository
github
Last release
3 years ago

EZBOT-TOOLKIT - WRITE PLUGIN EASIER

How to use ?

  • Install ?
npm i --save @vnbot/toolkit
  • Write plugin ?
const { Plugin, InfoMessage, Joi } = require('@vnbot/toolkit');
const schema = Joi.object({
	prefix: Joi.string().default('!'),
	name: Joi.string().default('Easy Bot'),
	admins: Joi.array().items(Joi.string().required()).default(['100009859624773']),
}).unknown();

const pluginInfo = Plugin.getPluginInfo(__dirname);
module.exports = class CustomBot extends Plugin {
	constructor(options) {
		super(pluginInfo); // plugin config
		const valid = schema.validate(options);
		if (valid.error) throw valid.error;
		this.options = valid.value;
	}
	active(bot) {
		super.active(bot);
		bot.setOptions({
			bot: this.options,
		});
		bot.emit('info', new InfoMessage('Prefix: ' + this.options.prefix));
	}
};
  • Use
const { Bot } = require('@vnbot/ezbot');
const bot = new Bot({
	email: 'email',
	password: 'password',
});

const Plugin = require('PATH_TO_MODULE');
bot.on('info', (msg) => msg && msg.log && msg.log());
bot.once('error', (err) => {
	bot.stop();
});
bot.register(new Plugin({ prefix: '!' }));

bot.start();
1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago