This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
68 lines (51 loc) · 2.04 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
const botconfig = require("./botconfig.json");
const Discord = require("discord.js");
const bot = new Discord.Client({disableEveryone: true});
const fs = require("fs");
const db = require("quick.db");
bot.commands = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if(jsfile.length <= 0){
console.log("Couldn't find commands.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
});
});
bot.on("ready", async () => {
console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
bot.user.setActivity(`Loading Online Users...`);
bot.user.setStatus('online');
})
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = botconfig.prefix
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot, message, args);
if(commandfile) db.add(`commandran_${message.guild.id}`, 1);
db.add(`messages_${message.guild.id}_${message.author.id}`, 1)
let messagefetch = db.fetch(`messages_${message.guild.id}_${message.author.id}`)
let messages;
if (messagefetch == 25) messages = 25; //Level 1
else if (messagefetch == 65) messages = 65; // Level 2
else if (messagefetch == 115) messages = 115; // Level 3
else if (messagefetch == 200) messages = 200; // Level 4
else if (messagefetch == 300) messages = 300; // Level 5
if (!isNaN(messages)) {
db.add(`level_${message.guild.id}_${message.author.id}`, 1)
let levelfetch = db.fetch(`level_${message.guild.id}_${message.author.id}`)
let levelembed = new Discord.RichEmbed()
.setDescription(`${message.author}, You have leveled up to level ${levelfetch}`)
message.channel.send(levelembed)
}
})
bot.login("");