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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
const Discord = require('discord.js');
const request = require('request');
const client = new Discord.Client();
const config = require('./config.json')
var prefix = "pug:";
var ver = "1.0.8";
var mcIP = '167.114.103.191';
var mcPort = 29239;
var suggestStates = {};
client.on("ready", () => client.user.setGame("For help: pug:help"));
client.on("guildMemberAdd", function(member) {
member.guild.channels.find("name", "welcome-and-bye").sendMessage(member.toString() + ", Welcome to the PugCraft Server! Have a great time here :wink:");
});
client.on("guildMemberRemove", function(member) {
member.guild.channels.find("name", "welcome-and-bye").sendMessage(member.toString() + ", just left the server");
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
let command = message.content.split(" ")[0];
command = command.slice(prefix.length);
let args = message.content.split(" ").slice(1);
if(command === 'help'){
var embed = new Discord.RichEmbed()
.addField('Commands for PugCraft Bot!\n\n',
'**'+prefix+'profile** Shows your profile pic in a image\n' +
"**"+prefix+"ping** Type this command and you'll see ;)\n" +
'**'+prefix+'about** Shows who made this bot\n' +
'**'+prefix+'status** It tells the status of the PugCraft server!\n' +
"**"+prefix+"ask** Go ask PugCraft Bot a question let's see what he's response!\n\n" +
"**The version that PugCraft Bot's running is " + ver + "!**", true)
.setColor("#fa00ff")
message.channel.sendEmbed(embed);
}
if(command === 'profile'){
message.reply(message.author.avatarURL);
}
if(command === 'ping'){
message.reply('Pong! :ping_pong:');
}
if(command === 'about'){
message.channel.send ('The person who made this is Alee14#9928! And it was based of the code AleeBot.');
}
if (command === 'status') {
var url = 'http://mcapi.us/server/status?ip=' + mcIP + '&port=' + mcPort;
request(url, function(err, response, body) {
if(err) {
console.log(err);
return message.reply('Error getting Minecraft server status...');
}
body = JSON.parse(body);
var status = '*PugCraft server is currently offline*';
if(body.online) {
status = '**PugCraft** server is **online** - ';
if(body.players.now) {
status += '**' + body.players.now + '** people are playing!';
} else {
status += '*Nobody is playing!*';
}
}
message.reply(status);
});
}
if(command === 'ask'){
var abaskanswer = [
"Yes.",
"No.",
"Maybe.",
"I don't know?",
"Hmm let me think :thinking:"
];
if (args[1]) {
message.channel.sendMessage(abaskanswer[Math.floor(Math.random() * abaskanswer.length)]);
} else {
message.channel.sendMessage("Sorry, I don't know what your saying.")
}
}
if(command === 'say'){
if(message.author.id !== "242775871059001344") return;
message.channel.sendMessage(args.join(" "));
message.delete();
}
});
process.on('unhandledRejection', function(err, p) {
console.log("[ERROR | UNCAUGHT PROMISE] " + err.stack);
});
console.log("[SUCCESS] PugCraft Bot is now ready! Running version "+ ver +"!");
client.login(config.token)
|