-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
53 lines (40 loc) · 1.47 KB
/
main.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
45
46
47
48
49
50
51
52
53
require('dotenv').config()
console.log("Welcome to Tentakelbot. Your interactive bot");
const Discord = require('discord.js')
const client = new Discord.Client();
const PluginManager = require('./PluginManager.js');
/* Plugins */
const GenericPlugin = require('./Plugin.js');
const Joker = require('./Joker.js');
const Day = require('./Day.js');
const GameNight = require('./GameNight.js');
var plugins = new PluginManager();
plugins.register(new GenericPlugin());
plugins.register(new Joker());
plugins.register(new Day());
plugins.register(new GameNight());
setInterval(() => {plugins.tick(client)}, 5000);
client.on('ready', () => {
console.log('I am logged in!');
});
client.on('message', msg => {
console.log('got message from ' + msg.author.username);
if(msg.author == client.user){
console.log("Message from myself. Ignoring. I am not one to talk to myself");
return; // from myself
}
if(msg.cleanContent.startsWith("!")){
var params = msg.cleanContent.split(" ");
var command = params[0].substring(1);
console.log("Got command " + command);
//remove command from params
params.shift();
if(plugins.hasCommand(command)){
console.log("There is a plugin to handle this");
plugins.runCommand(command, msg, params);
} else {
console.log("Could not find any plugin to handle. Sleeping.");
}
}
} );
client.login(process.env.DISCORD_BOT_TOKEN)