-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
46 lines (39 loc) · 1.23 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
const discord = require("discord.js");
const client = new discord.Client();
const config = require("./config.json");
const help = require("./messages/help.json");
const welcome = require("./messages/welcome.json");
client.on("ready", () => {
console.log("I am ready!");
});
client.on("message", message => {
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
if (!message.member.roles.some(r => ["Administrators"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
const args = message.content
.slice(config.prefix.length)
.trim()
.split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "help") {
let [person, msg] = args;
for (let cmd in help) {
if (help.hasOwnProperty(cmd)) {
if (msg === cmd) {
message.channel.send({
embed: help[cmd]
});
}
}
}
}
});
client.on("guildMemberAdd", member => {
if (member.id) {
client.users.get(member.id).send({
embed: welcome.message
});
}
});
client.login(config.token);