-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (41 loc) · 1.47 KB
/
app.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
const Discord = require('discord.js');
const client = new Discord.Client
const fs = require('fs')
client.commands = new Discord.Collection()
fs.readdir("./commands/", (err, files) => {
if(err) console.error(err);
let jsfiles = files.filter(f => f.split(".").pop() === ("js"));
if(jsfiles.length <= 0) {
return;
};
console.log(`Loading ${jsfiles.length} commands!`);
jsfiles.forEach((f, i) => {
let props = require(`./commands/${f}`);
console.log(`${i + 1}: ${f} loaded!`);
client.commands.set(props.help.name, props);
});
});
//This command was made to say if it's online in the console and what game it's playing.
client.on('ready',() => {
console.log('I\'m Online\n');
console.log(client.commands);
client.user.setGame("use -help");
});
//This command shows if someone has joined the server!
client.on('guildMemberAdd', member => {
const channel = member.guild.channels.find('name', 'member-log');
if (!channel) return;
channel.send(`Welcome to the server, ${member}`);
});
var prefix = "-"
client.on('message', message => {
if (message.author.bot) return;
let messageArray = message.content.split(/\s+/g);
let command = messageArray[0];
let args = messageArray.slice(1);
if (!message.content.startsWith(prefix)) return;
let commands = client.commands.get(command.slice(prefix.length));
if (commands) commands.run(client, message, args)
});
//This is the token.
client.login("NDgyNTQyMzU2ODczMzQ3MDcy.DmGaRg.XFmjDzYdCXgCVtgkCNgQjdXe7B4");