-
Notifications
You must be signed in to change notification settings - Fork 17
/
alpha.js
63 lines (46 loc) · 1.78 KB
/
alpha.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
54
55
56
57
58
59
60
61
62
63
// PACKAGES
const Discord = require('discord.js');
const config = require('./configs/config.json');
const fs = require('fs');
const db = require('quick.db');
const path = require("path");
const alexa = require("alexa-bot-api");
var chatbot = new alexa("chat bot api");
const client = new Discord.Client();
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
const { Player } = require('discord-player');
const player = new Player(client);
client.player = player;
client.emotes = require('./configs/emotes.json')
client.filters = require('./configs/filters.json');
["aliases", "commands"].forEach(cmd => client[cmd] = new Discord.Collection());
["console", "command", "event"].forEach(events => require(`./handlers/${events}`)(client));
client.categories = fs.readdirSync('./commands');
fs.readdir('./player/', (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./player/${file}`);
let eventName = file.split(".")[0];
console.log(`Loading player event ${eventName}`);
client.player.on(eventName, event.bind(null, client));
});
});
// EVENTS
client.on('ready', async() => {
console.log('Alpha Started!');
});
//CHATBOT FEATURE
client.on("message", async message => {
let sChannel = db.fetch(`chatbot_${message.guild.id}`);
if (sChannel === null) {
return;
}
if (message.author.bot && message.author.discriminator !== '0000') return;
if(message.channel.id === sChannel){
let content = message.content;
if(!content) return;
chatbot.getReply(content).then(r => client.channels.cache.get(sChannel).send(r));
}
});
client.login(config.token)