This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (43 loc) · 1.56 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
const botconfig = require("./botconfig.json");
const token = require("./settings.json");
const Discord = require('discord.js');
const bcrypt = require("bcryptjs");
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();
const fs = require("fs");
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);
});
})
var servers = {};
bot.on("ready", async () =>{
function randomStatus() {
let status = ["status 1", "status 2", "status 3"]
let rStatus = Math.floor(Math.random() * status.length);
bot.user.setActivity(status[rStatus], {type: "PLAYING"});
}; setInterval(randomStatus, 2000)
console.log(`${bot.user.username} Is online!`);
})
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
if(message.channel.type === "embed") return;
let prefix = config.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0].toLowerCase();
let args = messageArray.slice(1);
if (message.content.startsWith(prefix)) {
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot,message,args);
}
});
bot.login(token)