-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (31 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const Discord = require('discord.js');
const client = new Discord.Client();
const Botinok = require('./Botinok');
let botinok = null;
const start = (config) => {
if(botinok) throw new Error('already started');
let token = config.token;
let prefix = config.prefix;
let ownerId = config.ownerId;
let status = config.status;
if(!token) throw new Error('token required');
if(!prefix) throw new Error('prefix required');
botinok = new Botinok({ownerId, prefix, status});
botinok.setClient(client);
client.login(token);
return client;
};
const addModule = (config) => {
if(!botinok) throw new Error('start the bot first');
if(!config.name) throw new Error('module name required');
if(!config.commands) throw new Error('module commands required');
config.isMiddleware = false;
botinok.addModule(config);
};
const addMiddleware = (config) => {
if(!botinok) throw new Error('start the bot first');
if(!config.name) throw new Error('module name required');
config.isMiddleware = true;
botinok.addModule(config);
};
module.exports = { start, addModule, addMiddleware };