-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
79 lines (42 loc) · 1.59 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
const discord = require("discord.js");
const botConfig = require("./botconfig.json");
const fs = require("fs");
const client = new discord.Client();
client.commands = new discord.Collection();
fs.readdir("./commands/" , (err, files) =>{
if(err) console.log(err);
var jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.lenght <= 0){
console.log("geen files te vinden");
return;
}
jsfiles.forEach((f, i) =>{
var fileGet = require(`./commands/${f}`);
console.log(`de file ${f} is geladen`);
client.commands.set(fileGet.help.name, fileGet);
});
client.on("discord.GuildMemberAdd", member =>{
var role = member.guild.roles.cache.get('847445119905038398');
if(!role) return;
member.roles.add(role);
var channel = member.guild.channels.cache.get('847445833988702248');
if(!channel) return;
channel.send(`welkom bij de server ${member}`);
});
});
client.login(botConfig.token);
client.on("ready", async () =>{
console.log(`${client.user.username} is online.`);
client.user.setActivity("Enli nu in js", {type: "LISTENING"})
});
client.on("message", async message =>{
if(message.author.bot) return;
if(message.channel.type == "dm") return;
var prefix = botConfig.prefix;
var messageArray = message.content.split(" ");
var command = messageArray[0];
if(!message.content.startsWith(prefix)) return;
var args = messageArray.slice(1);
var commands = client.commands.get(command.slice(prefix.length));
if(commands) commands.run(client, message, args)
});