-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (55 loc) · 1.86 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
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require("./config.json")
client.on('ready', () => {
console.log('I am ready!');
});
client.on("guildMemberAdd", member => {
let guild = member.guild;
guild.defaultChannel.sendMessage(`Welcome ${member.user} to this server.`);
});
client.on("guildCreate", guild => {
console.log(`New guild added : ${guild.name}, owned by ${guild.owner.user.username}`)
});
client.on("presenceUpdate", (oldMember, newMember) => {
let guild = newMember.guild;
let playRole = guild.roles.find("name", "Playing Minecraft");
if(!playRole) return;
if(newMember.user.presence.game && newMember.user.presence.game.name.startsWith("Minecraft")) {
newMember.addRole(playRole);
}else if(!newMember.user.presence.game && newMember.roles.has(playRole.id)) {
}
});
client.on('message', message => {
if(message.author.bot) return;
if(!message.content.startsWith(config.prefix)) return;
let command = message.content.split(" ")[0];
command = command.slice(config.prefix.length);
let args = message.content.split(" ").slice(1);
if (command === "math") {
let numArray = args.map(n=> parseInt(n));
let math = args[1];
if (math === "+") {
message.channel.sendMessage(numArray[0] + numArray[2]);
}
if (math === "-") {
message.channel.sendMessage(numArray[0] - numArray[2]);
}
if (math === "/") {
message.channel.sendMessage(numArray[0] / numArray[2]);
}
if (math === "*") {
message.channel.sendMessage(numArray[0] * numArray[2]);
}
}
if (command === "say") {
message.channel.sendMessage(args.join(" "));
}
if (command === "ping") {
message.channel.sendMessage("pong");
} else
if (command === "foo") {
message.channel.sendMessage("bar!");
}
});
client.login(config.token);