-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
387 lines (341 loc) · 12.3 KB
/
main.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require('./config.json')
const fs = require("fs")
const rbx = require('roblox-js');
const os = require("os");
client.on('ready', () => {
console.log(`Ready to server on 1 server, for ${client.users.size} users.`);
client.user.setPresence({
game: {
name :(`Testing Beta Phase, for ${client.users.size} users.`),
type: 0
}
});
client.guilds.array().forEach(function(element) {
},);
});
const prefix = config.prefix
client.on('message', message => {
if (message.author.bot) return;
// Return if it is a DM
// Saving memory, if there is no prefix it quits.
if (!message.content.slice(1) === prefix) return;
//Function for command checking
function commandIs(command) {
if (message.content.startsWith(prefix + command)) {
return true;
}
}
if(message.member.roles.find("name", "GUEST")){
let member = message.guild.member(message.author);
member.setNickname(`[${member.highestRole.name}] ${member.user.username}`)
}
if(commandIs("activitycheck")){
message.channel.send("You have **0** players playing your game. (ERROR:1 YOUR GAME HAS NOT BEEN CREATED)")
}
if(commandIs("donate")){
try {
let donationmenu = {
embed: {
color: 0xd38cff,
title: "Invite Links",
description: "Thank you for using hexcore Beta the bot! To donate to the creators of the bot as a thank you, here are some links you can check out.",
fields: [{
name: "**PayPal (preferred)**",
value: `https://paypal.me/heotech`
},
{
name: "**Patreon (for monthly donations)**",
value: `https://www.patreon.com/joeyheo`
},
{
name: "If you donate, you will be able to get a Donator role in my Discord server!",
value: "https://discord.gg/CjDywuX"
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "hexcore beta"
}
}
}
message.channel.send(donationmenu)
} catch (err) {
message.channel.send(ess.errorHandle(err));
}
}
if(commandIs("serverinfo")){
try {
let guild = message.guild
const embed = new Discord.RichEmbed()
.setDescription("Description and information about this server")
.setColor(3447003)
.setThumbnail(guild.iconURL)
.setTimestamp(new Date())
.addField("Name", guild.name, true)
.addField("ID", guild.id, true)
.addField("Owner", guild.owner.user.tag, true)
.addField("Region", guild.region, true)
.addField("Verification Level", guild.verificationLevel, true)
.addField("Channels", guild.channels.array().length, true)
.addField("Members", guild.memberCount, true)
.addField("Creation Date", guild.createdAt, true)
message.channel.send(embed)
return;
} catch (err) {
console.log(err);
message.channel.send(ess.errorHandle(err));
}
}
if(commandIs("userinfo")){
try {
if (message.mentions.members.first()) {
let member = message.mentions.members.first().user
let guildMember = message.mentions.members.first()
const embed = new Discord.RichEmbed()
.setDescription("Description and information about " + member.tag)
.setAuthor(member.username, member.displayAvatarURL)
.setColor(3447003)
.setThumbnail(member.displayAvatarURL)
.setTimestamp(new Date())
.setFooter("hexcore Beta", client.user.avatarURL)
.addField("ID", member.id)
.addField("Discriminator", member.discriminator)
.addField("Status", member.presence.status)
.addField("Nickname", guildMember.nickname)
.addField("Moderator", guildMember.hasPermission("BAN_MEMBERS"))
.addField("Joined at", guildMember.joinedAt)
.addField("Role(s)", guildMember.roles.array().join(", "))
message.channel.send(embed)
} else {
let member = message.author
let guildMember = message.guild.member(member)
const embed = new Discord.RichEmbed()
.setDescription("Description and information about " + member.tag)
.setAuthor(member.username, member.displayAvatarURL)
.setColor(3447003)
.setThumbnail(member.displayAvatarURL)
.setTimestamp(new Date())
.setFooter("hexcore Beta", client.user.avatarURL)
.addField("ID", member.id)
.addField("Discriminator", member.discriminator)
.addField("Status", member.presence.status)
.addField("Nickname", guildMember.nickname)
.addField("Moderator", guildMember.hasPermission("BAN_MEMBERS"))
.addField("Joined at", guildMember.joinedAt)
.addField("Role(s)", guildMember.roles.array().join(", "))
message.channel.send(embed)
}
return;
} catch (err) {
message.channel.send(ess.errorHandle(err));
}
}
if (commandIs("creators")) {
const embed = new Discord.RichEmbed()
.setTitle("Creators of hexcore-beta")
.setDescription("People who made bot hexcore-beta successful and become better than anything before.")
.setColor(0x70b080)
.addField("Creator", "ExternalMixture")
.addField("Developers", "ExternalMixture")
.addField("GFX Artists", "ExternalMixture")
.setFooter("hexcore-beta", client.user.avatarURL)
.setThumbnail(client.user.avatarURL)
message.channel.send(embed);
}
if (commandIs("help")) {
const embed = new Discord.RichEmbed()
.setTitle("Commands List for hexcore-beta")
.setDescription(`All the commands provided for the release version of hexcore-beta. Default prefix is ${prefix}`)
.setColor(0x70b080)
.addField("help", "This help panel")
.addField("userinfo", "Information about user in the server")
.addField("creators", "Credits for the bot")
.addField("purge", "Delete a bulk load of messages (100 max)")
.addField("buy", "Gives invite to the xAtom main server | Price")
.addField("serverinfo", "Gives all of the information of the server")
.addField("botstatus" , "bot status from heroku hosting server.")
.addField("info", "gives you information")
.addField("membercount", "counts member in the server,")
.setFooter("hexcore-beta", client.user.avatarURL)
.setThumbnail(client.user.avatarURL)
message.channel.send(embed);
}
if(commandIs("botstatus")){
try {
//CPU Stuff
function cpuAverage() {
var totalIdle = 0,
totalTick = 0;
var cpus = os.cpus();
for (var i = 0, len = cpus.length; i < len; i++) {
var cpu = cpus[i];
for (type in cpu.times) {
totalTick += cpu.times[type];
}
totalIdle += cpu.times.idle;
}
return {
idle: totalIdle / cpus.length,
total: totalTick / cpus.length
};
}
var startMeasure = cpuAverage();
setTimeout(function() {
var endMeasure = cpuAverage();
var idleDifference = endMeasure.idle - startMeasure.idle;
var totalDifference = endMeasure.total - startMeasure.total;
var percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);
//CPU STUFF OVER
var botMembers = client.users.size
//HHMMSS
String.prototype.toHHMMSS = function() {
var sec_num = parseInt(this, 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var time = hours + ':' + minutes + ':' + seconds;
return time;
}
//
const rich = new Discord.RichEmbed()
.setTitle("Server Internal Status")
.setDescription("Shows you the internal specification of the server's status")
.setColor(0xd38cff)
.setThumbnail("https://nodejs.org/static/images/logo-hexagon.png")
.setTimestamp(new Date())
.setFooter("hexcore beta", client.user.avatarURL, true)
.addField("CPU Percentage", `${percentageCPU}%`, true)
.addField("RAM Usage", `${Math.round(process.memoryUsage().heapUsed/ 1024 / 1024 * 100) / 100} MB`, true)
.addField("Uptime", `${process.uptime().toString().toHHMMSS()}`, true)
.addField("Guilds", client.guilds.array().length, true)
.addField("Users", botMembers, true)
.addField("Bot Version", `beta`, true)
message.channel.send(rich);
},
100);
return;
} catch (err) {
message.channel.send(ess.errorHandle(err));
}
}
if(commandIs("info")){
message.channel.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: "hexcore Beta",
url: "",
description: "Hexcore beta was created by ExternalMixture#3252, the current status is beta",
fields: [
{
name: "Support server",
value: "Join our support server [here](https://discord.gg/CjDywuX)"
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "hexcore Beta"
}
}
});
}
if(commandIs("buy")){
message.channel.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: "hexcore Beta",
url: "",
description: "hexcore Beta helps you connect your discord server and your roblox group.",
fields: [
{
name: "Plan",
value: "You can find monthly plan [here](https://docs.google.com/document/d/1ifi0dCPOgsRpdPx0K_LzqjrTmb8vB1KxUyw30SvMIYg/edit?usp=sharing)"
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "hexcore Beta"
}
}
});
}
if(commandIs('update', message)){
message.channel.send("All of the commands are disabled in current server.")
}
if(commandIs("membercount")){
try {
let guild = message.guild
const embed = new Discord.RichEmbed()
.setDescription("membercount")
.setColor(3447003)
.setThumbnail(guild.iconURL)
.setTimestamp(new Date())
.addField("Name", guild.name, true)
.addField("ID", guild.id, true)
.addField("Owner", guild.owner.user.tag, true)
.addField("Members", guild.memberCount, true)
message.channel.send(embed)
return;
} catch (err) {
console.log(err);
message.channel.send(ess.errorHandle(err));
}
}
if(commandIs('listrank', message)){
let groupID = 4590447;
if(message.member.hasPermission('ADMINISTRATOR')){
message.channel.send("Loading all ranks from the follow group " + ' https://www.roblox.com/groups/group.aspx?gid='+ groupID )
rbx.getRoles(4590447)
.then(function (roles) {
roles.forEach(function(item){
message.channel.send('"' + item.Name + '",')
})
})
}
}
if(commandIs("tagme", message)){
message.channel.send("All of the commands are currently disabled.")
}
if (commandIs("purge")) {
if (message.member.hasPermission("MANAGE_MESSAGES")) {
try {
if (!Number(message.content.split(" ")[1])) {
message.channel.send("Please provide a number for amount of messages to be deleted.")
return;
}
let deleteCount = parseInt(message.content.split(" ")[1])
if (deleteCount > 99) {
message.channel.send("Please try lower number than 100.");
return;
}
message.channel.fetchMessages({
limit: deleteCount + 1
}).then(messages => message.channel.bulkDelete(messages));
message.channel.send("Purged and cleared!").then(msg => msg.delete())
} catch (err) {
message.channel.send(ess.errorHandle(err));
}
}
}
})
// Return if it is a bot
client.login(process.env.TOKEN);