-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathbot.js
73 lines (53 loc) · 2.01 KB
/
bot.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
const botSettings = require("./botsettings.json")
const Discord = require("discord.js");
const fs = require("fs");
const ytdl = require("ytdl-core");
const request = require("request");
const client = new Discord.Client();
const prefix = botSettings.prefix;
const DBL = require("dblapi.js");
const dbl = new DBL(process.env.dblapi, client);
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();
fs.readdir("./cmds", (err, files) => {
if(err) console.error(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
console.log("No commands found to load!");
return;
}
console.log(`Loading ${jsfiles.length} commands!`);
jsfiles.forEach((f, i) => {
let props = require(`./cmds/${f}`);
console.log(`${i + 1}: ${f} loaded!`);
bot.commands.set(props.help.name, props);
});
});
bot.on("ready", async () => {
console.log(`Bots is ready and working in ${bot.guilds.size} servers with ${bot.users.size} users!`);
dbl.postStats(bot.guilds.size);
/*setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 1800000); */
bot.user.setStatus('Online')
bot.user.setActivity(`in ${bot.guilds.size}/200 Servers | !help`);
bot.channels.get("521378814467506176").setName(`Servers: ${bot.guilds.size}/100`)
try {
let link = await bot.generateInvite(["ADMINISTRATOR"]);
console.log(link);
} catch(e) {
console.log(e.stack);
}
});
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let messageArray = message.content.split(" ");
let command = messageArray[0];
let args = messageArray.slice(1);
if(!command.startsWith(prefix)) return;
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot, message, args);
});
bot.login(process.env.token);
//restart