-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
152 lines (137 loc) · 4.38 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
const Discord = require('discord.js');
const bot_settings = require('./botconfig.json');
const fs = require('fs');
const bot = new Discord.Client()
bot.commands = new Discord.Collection()
bot.musicQueue = new Discord.Collection()
bot.mongoose = require('./utils/mongoose')
fs.readdir('./commands/actions/',(err,files)=>{
if (err){
console.log(`Cannot find the directory /actions/`)
} else {
let jsFile = files.filter(f => f.split(".").pop()==='js')
if (jsFile.length<=0){
console.log("The action command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/actions/${f}`);
bot.commands.set(props.help.name,props)
})
console.log(`${jsFile.length} action commands were loaded into module.`)
}
}
})
fs.readdir("./commands/anime/", (err,files)=>{
if (err){
console.log('Cannot find the directory /anime/')
} else {
let jsFile = files.filter(f => f.split(".").pop()==="js")
if (jsFile.length <=0){
return console.log("The anime command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/anime/${f}`);
bot.commands.set(props.help.name, props)
});
console.log(`${jsFile.length} anime commands successfully loaded into module.`)
}
}
})
fs.readdir("./commands/core/",(err,files)=>{
if (err){
console.log('Cannot find the directory /core/')
} else {
let jsFile = files.filter(f => f.split(".").pop()==="js")
if (jsFile.length <=0){
return console.log("The core command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/core/${f}`);
bot.commands.set(props.help.name, props)
});
console.log(`${jsFile.length} core commands successfully loaded into module.`)
}
}
})
fs.readdir('./commands/fun/',(err,files)=>{
if (err){
console.log(`Cannot find the directory /fun/`)
} else {
let jsFile = files.filter(f => f.split(".").pop()==='js')
if (jsFile.length<=0){
console.log("The fun command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/fun/${f}`);
bot.commands.set(props.help.name,props)
})
console.log(`${jsFile.length} fun commands were loaded into module.`)
}
}
})
fs.readdir('./commands/moderator/',(err,files)=>{
if (err){
console.log(`Cannot find the directory /moderator/`)
} else {
let jsFile = files.filter(f => f.split(".").pop()==='js')
if (jsFile.length<=0){
console.log("The modarator command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/moderator/${f}`);
bot.commands.set(props.help.name,props)
})
console.log(`${jsFile.length} modeartor commands were loaded into module.`)
}
}
})
fs.readdir('./commands/utility/',(err,files)=>{
if (err) {
console.log(`Cannot find the directory /utility/`)
} else {
let jsFile = files.filter(f => f.split(".").pop()==='js')
if (jsFile.length<=0){
console.log("The utility command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/utility/${f}`);
bot.commands.set(props.help.name,props)
})
console.log(`${jsFile.length} utility commands were loaded into module.`)
}
}
})
fs.readdir('./commands/music/',(err,files)=>{
if (err) {
console.log(`Cannot find the directory /music/`)
} else {
let jsFile = files.filter(f => f.split(".").pop()==='js')
if (jsFile.length<=0){
console.log("The music command database are empty.")
} else {
jsFile.forEach((f,i)=>{
let props = require(`./commands/music/${f}`);
bot.commands.set(props.help.name,props)
})
console.log(`${jsFile.length} music commands were loaded into module.`)
}
}
})
fs.readdir("./events/", (err,files)=>{
if (err) console.log(err)
let evtFiles = files.filter(f=>f.split(".").pop()==="js")
if (evtFiles.length<=0){
return console.log(`Couldn't find events`);
}
evtFiles.forEach(file => {
const eventName = file.split(".")[0];
console.log(`${eventName} event loaded!`)
const event = require(`./events/${file}`)
bot.on(eventName, event.bind(null, bot));
})
})
process.on('unhandledRejection', err => {
console.error('Uncaught Promise Error! \n' + err.stack);
});
bot.mongoose.init();
bot.login(process.env.BOT_TOKEN)