-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
67 lines (48 loc) · 1.52 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
const Discord = require("discord.js"),
path = require("path"),
fs = require("fs");
module.exports = {
version: require("./package.json").version,
start(client, Prefix){
if(!client){
throw new Error("No client found.");
}
if(!Prefix) return console.log("[economy-uplife]⚠️:{please give me prefix}");
const bot = client;
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
fs.readdir(__dirname+"/eco/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if(jsfile.length <= 0){
return;
}
jsfile.forEach((f, i) =>{
let props = require(__dirname+`/eco/${f}`);
bot.commands.set(props.help.name, props);
props.help.aliases.forEach(alias => {
bot.aliases.set(alias, props.help.name);
});
});
})
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = db.get(`prefix_${message.guild.id}`)||Prefix;
let messageArray = message.content.split(" ");
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
let commandfile;
if (bot.commands.has(cmd)) {
commandfile = bot.commands.get(cmd);
} else if (bot.aliases.has(cmd)) {
commandfile = bot.commands.get(bot.aliases.get(cmd));
}
if (!message.content.startsWith(prefix)) return;
try {
commandfile.run(bot, message, args);
} catch (e) {
}
});
}
}