· 6 years ago · Dec 25, 2019, 03:24 PM
1//BY:Samurai - EdiTeD -
2
3const Discord = require("discord.js");
4const bot = new Discord.Client({ disableEveryone: false });
5let client = bot;
6const ms = require("ms");
7const fs = require("fs");
8var request = require("request");
9const Jimp = require('jimp');
10const diff = require('color-diff');
11const getJSON = require('get-json');
12const download = require('image-downloader');
13var cheerio = require("cheerio");
14const talkedRecently = new Set();
15client.on("ready", function() {
16 client.user.setAc"Samurai");
17 console.log('شغال')
18 });
19
20client.on("message", message => {
21 let msg = message;
22 let prefix = `!!`
23 let messageArray = message.content.split(" ");
24 let cmd = messageArray[0].toLowerCase();
25 let args = messageArray.slice(1);
26
27 if (!message.content.startsWith(prefix)) return;
28 if(cmd === `${prefix}blocks`){
29 if (message.author.id === bot.user.id) return;
30 let [player, lol, ...rest] = args;
31 let page = parseInt(lol, 10);
32 if(!player) return message.reply(`**Usage: \`${prefix}blocks <Player Name> [page]\`**`);
33 request(`https://blocksmc.com/player/${player}`, (err,res,html)=>{
34 if(err || res.statusCode != 200) return message.channel.send('There seems to be an error with the API. Try again later. :confounded:');
35 if (!err && res.statusCode == 200){
36 const $ = cheerio.load(html);
37 const userName = $('.profile-header').find('h1').text();
38 if (!userName) return message.channel.send("Player not found")
39 const userTime = $('.gray-cont').find('h1').text().trim();
40 const userRankData = $('.profile-rank');
41 const userRank = userRankData.text().trim();
42 let userHexColor;
43 if(userRank === "Member") userHexColor = "#2b76aa";
44 else if(userRank === "Owner") userHexColor = "#fff000";
45 else if(userRank === "VIP Member") userHexColor = "#ba50e7";
46 else if(userRank === "Moderator") userHexColor = "#e76250";
47 else if(userRank === "Senior Moderator") userHexColor = "#841818";
48 else if(userRank === "Admin") userHexColor = "#841818";
49 else if(userRank === "Head Admin") userHexColor = "#841818";
50 else if(userRank === "Emerald Member") userHexColor = "#00a86b";
51 else if(userRank === "Diamond Member") userHexColor = "#01c5b8";
52 else if(userRank === "Gold Member") userHexColor = "#f3bc00";
53 else if(userRank === "Dev") userHexColor = "#202020";
54 else userHexColor = "#2b76aa";
55 let getData = function(key, value){
56 let text = $(`#${key} #${value}.val`).text();
57 return parseInt(text,10);
58 }
59 const stats = {
60 //BlocksParty
61 BP: {
62 points: getData(`BP`, `Points`),
63 wins: getData(`BP`, `Wins`),
64 played: getData(`BP`, `Played`),
65 image: "https://blocksmc.com/images/pfavatars/BlockParty.png"
66 },
67 //Splegg
68 SP: {
69 points: getData(`SP`, `Points`),
70 eggs: getData(`SP`, `Eggs`),
71 blocks: getData(`SP`, `Blocks`),
72 wins: getData(`SP`, `Wins`),
73 played: getData(`SP`, `Played`),
74 image: "https://blocksmc.com/images/pfavatars/Splegg.png"
75 },
76 //QuakeCraft
77 QC: {
78 points: getData(`QC`, `Points`),
79 kills: getData(`QC`, `Kills`),
80 deaths: getData(`QC`, `Deaths`),
81 fireworks: getData(`QC`, `FireWorks`),
82 wins: getData(`QC`, `Wins`),
83 played: getData(`QC`, `Played`),
84 image: "https://blocksmc.com/images/pfavatars/QuakeCraft.png"
85 },
86 //Gravity
87 GR: {
88 points: getData(`GR`, `Points`),
89 wins: getData(`GR`, `Wins`),
90 played: getData(`GR`, `Played`),
91 image: "https://blocksmc.com/images/pfavatars/Gravity.png"
92 },
93 //SurvivalGames
94 SG: {
95 points: getData(`SG`, `Points`),
96 kills: getData(`SG`, `Kills`),
97 deaths: getData(`SG`, `Deaths`),
98 wins: getData(`SG`, `Wins`),
99 crates: getData(`SG`, `Crates`),
100 played: getData(`SG`, `Played`),
101 image: "https://blocksmc.com/images/pfavatars/SurvivalGames.png"
102 },
103 //LuckyBlockWars
104 LBW: {
105 points: getData(`LBW`, `Points`),
106 kills: getData(`LBW`, `Kills`),
107 deaths: getData(`LBW`, `Deaths`),
108 wins: getData(`LBW`, `Wins`),
109 sponges: getData(`LBW`, `Sponges`),
110 played: getData(`LBW`, `Played`),
111 image: "https://blocksmc.com/images/pfavatars/LuckyBlockWars.png"
112 },
113 //EggWars
114 EW: {
115 points: getData(`EW`, `Points`),
116 kills: getData(`EW`, `Kills`),
117 deaths: getData(`EW`, `Deaths`),
118 wins: getData(`EW`, `Wins`),
119 eggs: getData(`EW`, `Eggs`),
120 played: getData(`EW`, `Played`),
121 image: "https://blocksmc.com/images/pfavatars/EggWars.png"
122 },
123 //EggWars:Solo
124 EWS: {
125 points: getData(`EWS`, `Points`),
126 kills: getData(`EWS`, `Kills`),
127 deaths: getData(`EWS`, `Deaths`),
128 wins: getData(`EWS`, `Wins`),
129 eggs: getData(`EWS`, `Eggs`),
130 played: getData(`EWS`, `Played`),
131 image: "https://blocksmc.com/images/pfavatars/EggWarsSolo.png"
132 },
133 //BedWars
134 BW: {
135 points: getData(`BW`, `Points`),
136 kills: getData(`BW`, `Kills`),
137 deaths: getData(`BW`, `Deaths`),
138 wins: getData(`BW`, `Wins`),
139 beds: getData(`BW`, `Beds`),
140 played: getData(`BW`, `Played`),
141 image: "https://blocksmc.com/images/pfavatars/BedWars.png"
142 },
143 //BedWars:Solo
144 BWS: {
145 points: getData(`BWS`, `Points`),
146 kills: getData(`BWS`, `Kills`),
147 deaths: getData(`BWS`, `Deaths`),
148 wins: getData(`BWS`, `Wins`),
149 beds: getData(`BWS`, `Beds`),
150 played: getData(`BWS`, `Played`),
151 image: "https://blocksmc.com/images/pfavatars/BedWarsSolo.png"
152 },
153 //SkyWars
154 SW: {
155 points: getData(`SW`, `Points`),
156 kills: getData(`SW`, `Kills`),
157 deaths: getData(`SW`, `Deaths`),
158 wins: getData(`SW`, `Wins`),
159 played: getData(`SW`, `Played`),
160 image: "https://blocksmc.com/images/pfavatars/SkyWars.png"
161 },
162 //SkyWars:Solo
163 SWS: {
164 points: getData(`SWS`, `Points`),
165 kills: getData(`SWS`, `Kills`),
166 deaths: getData(`SWS`, `Deaths`),
167 wins: getData(`SWS`, `Wins`),
168 played: getData(`SWS`, `Played`),
169 image: "https://blocksmc.com/images/pfavatars/SkyWarsSolo.png"
170 },
171 //SkyGiant
172 GNT: {
173 points: getData(`GNT`, `Points`),
174 kills: getData(`GNT`, `Kills`),
175 deaths: getData(`GNT`, `Deaths`),
176 wins: getData(`GNT`, `Wins`),
177 played: getData(`GNT`, `Played`),
178 image: "https://blocksmc.com/images/pfavatars/SkyGiant.png"
179 },
180 //SkyGiant Mini
181 GNTM: {
182 points: getData(`GNTM`, `Points`),
183 kills: getData(`GNTM`, `Kills`),
184 deaths: getData(`GNTM`, `Deaths`),
185 wins: getData(`GNTM`, `Wins`),
186 played: getData(`GNTM`, `Played`),
187 image: "https://blocksmc.com/images/pfavatars/SkyGiantMini.png"
188 },
189 //The Bridge
190 TB: {
191 points: getData(`TB`, `Points`),
192 kills: getData(`TB`, `Kills`),
193 deaths: getData(`TB`, `Deaths`),
194 wins: getData(`TB`, `Wins`),
195 goals: getData(`TB`, `Goals`),
196 played: getData(`TB`, `Played`),
197 image: "https://blocksmc.com/images/pfavatars/TheBridge.png"
198 },
199 //1VS1
200 oneVSone: {
201 points: getData(`1VS1`, `Points`),
202 kills: getData(`1VS1`, `Kills`),
203 deaths: getData(`1VS1`, `Deaths`),
204 wins: getData(`1VS1`, `Wins`),
205 rounds: getData(`1VS1`, `Rounds`),
206 played: getData(`1VS1`, `Played`),
207 image: "https://blocksmc.com/images/pfavatars/1VS1.png"
208 },
209 };
210 request.get(`https://api.mojang.com/users/profiles/minecraft/${userName}`, (err, res, body)=>{
211
212 if(!err && res.statusCode === 200){
213 message.channel.startTyping()
214 body = JSON.parse(body);
215 let image = `https://visage.surgeplay.com/full/250/${body.id}.png`;
216 for (const key in stats) {
217 if(`${stats[key].points}` === "NaN"){
218 delete stats[key];
219 };
220 };
221 const embed = new Discord.RichEmbed()
222 .setAuthor(userName, `https://minotar.net/helm/${userName}`, `https://blocksmc.com/player/${userName}`)
223 .addField("**Rank**", `\`${userRank}\``, true)
224 .addField("**Hours**", `\`${userTime}\``, true)
225 .setColor(userHexColor)
226 .setImage(image)
227 .setThumbnail("https://cdn.discordapp.com/icons/211543198651121664/a4baa5a87ff496ef33430c795d5186ff.png")
228 let pages = [embed];
229 if(stats.hasOwnProperty("BP")){
230 const BPEmbed = new Discord.RichEmbed()
231 .addField("**Played:**", `\`${stats.BP.played}\``, true)
232 .addField("**Points:**", `\`${stats.BP.points}\``, true)
233 .addField("**Wins:**", `\`${stats.BP.wins}\``, true)
234 .setImage(stats.BP.image)
235 pages.push(BPEmbed);
236 }
237 if(stats.hasOwnProperty("SP")){
238 const SPEmbed = new Discord.RichEmbed()
239 .addField("**Points:**", `\`${stats.SP.points}\``, true)
240 .addField("**Wins:**", `\`${stats.SP.wins}\``, true)
241 .addField("**Played:**", `\`${stats.SP.played}\``, true)
242 .addField("**Eggs:**", `\`${stats.SP.eggs}\``, true)
243 .addField("**Blocks:**", `\`${stats.SP.blocks}\``, true)
244 .addBlankField(true)
245 .setImage(stats.SP.image)
246 pages.push(SPEmbed);
247 }
248 if(stats.hasOwnProperty("QC")){
249 const QCEmbed = new Discord.RichEmbed()
250 .addField("**Points:**", `\`${stats.QC.points}\``, true)
251 .addField("**Played:**", `\`${stats.QC.played}\``, true)
252 .addField("**Deaths:**", `\`${stats.QC.deaths}\``, true)
253 .addField("**Fireworks:**", `\`${stats.QC.fireworks}\``, true)
254 .addField("**Kills:**", `\`${stats.QC.kills}\``, true)
255 .addField("**Wins:**", `\`${stats.QC.wins}\``, true)
256 .setImage(stats.QC.image)
257 pages.push(QCEmbed);
258 }
259 if(stats.hasOwnProperty("GR")){
260 const GREmbed = new Discord.RichEmbed()
261 .addField("**Points:**", `\`${stats.GR.points}\``, true)
262 .addField("**Played:**", `\`${stats.GR.played}\``, true)
263 .addField("**Wins:**", `\`${stats.GR.wins}\``, true)
264 .setImage(stats.GR.image)
265 pages.push(GREmbed);
266 }
267 if(stats.hasOwnProperty("SG")){
268 const SGEmbed = new Discord.RichEmbed()
269 .addField("**Points:**", `\`${stats.SG.points}\``, true)
270 .addField("**Played:**", `\`${stats.SG.played}\``, true)
271 .addField("**Deaths:**", `\`${stats.SG.deaths}\``, true)
272 .addField("**Crates:**", `\`${stats.SG.crates}\``, true)
273 .addField("**Kills:**", `\`${stats.SG.kills}\``, true)
274 .addField("**Wins:**", `\`${stats.SG.wins}\``, true)
275 .setImage(stats.SG.image)
276 pages.push(SGEmbed);
277 }
278 if(stats.hasOwnProperty("LBW")){
279 const LBWEmbed = new Discord.RichEmbed()
280 .addField("**Points:**", `\`${stats.LBW.points}\``, true)
281 .addField("**Played:**", `\`${stats.LBW.played}\``, true)
282 .addField("**Deaths:**", `\`${stats.LBW.deaths}\``, true)
283 .addField("**Sponges:**", `\`${stats.LBW.sponges}\``, true)
284 .addField("**Kills:**", `\`${stats.LBW.kills}\``, true)
285 .addField("**Wins:**", `\`${stats.LBW.wins}\``, true)
286 .setImage(stats.LBW.image)
287 pages.push(LBWEmbed);
288 }
289 if(stats.hasOwnProperty("EW")){
290 const EWEmbed = new Discord.RichEmbed()
291 .addField("**Points:**", `\`${stats.EW.points}\``, true)
292 .addField("**Played:**", `\`${stats.EW.played}\``, true)
293 .addField("**Deaths:**", `\`${stats.EW.deaths}\``, true)
294 .addField("**Eggs:**", `\`${stats.EW.eggs}\``, true)
295 .addField("**Kills:**", `\`${stats.EW.kills}\``, true)
296 .addField("**Wins:**", `\`${stats.EW.wins}\``, true)
297 .setImage(stats.EW.image)
298 pages.push(EWEmbed);
299 }
300 if(stats.hasOwnProperty("EWS")){
301 const EWSEmbed = new Discord.RichEmbed()
302 .addField("**Points:**", `\`${stats.EWS.points}\``, true)
303 .addField("**Played:**", `\`${stats.EWS.played}\``, true)
304 .addField("**Deaths:**", `\`${stats.EWS.deaths}\``, true)
305 .addField("**Eggs:**", `\`${stats.EWS.eggs}\``, true)
306 .addField("**Kills:**", `\`${stats.EWS.kills}\``, true)
307 .addField("**Wins:**", `\`${stats.EWS.wins}\``, true)
308 .setImage(stats.EWS.image)
309 pages.push(EWSEmbed);
310 }
311 if(stats.hasOwnProperty("BW")){
312 const BWEmbed = new Discord.RichEmbed()
313 .addField("**Points:**", `\`${stats.BW.points}\``, true)
314 .addField("**Played:**", `\`${stats.BW.played}\``, true)
315 .addField("**Deaths:**", `\`${stats.BW.deaths}\``, true)
316 .addField("**Beds:**", `\`${stats.BW.beds}\``, true)
317 .addField("**Kills:**", `\`${stats.BW.kills}\``, true)
318 .addField("**Wins:**", `\`${stats.BW.wins}\``, true)
319 .setImage(stats.BW.image)
320 pages.push(BWEmbed);
321 }
322 if(stats.hasOwnProperty("BWS")){
323 const BWSEmbed = new Discord.RichEmbed()
324 .addField("**Points:**", `\`${stats.BWS.points}\``, true)
325 .addField("**Played:**", `\`${stats.BWS.played}\``, true)
326 .addField("**Deaths:**", `\`${stats.BWS.deaths}\``, true)
327 .addField("**Beds:**", `\`${stats.BWS.beds}\``, true)
328 .addField("**Kills:**", `\`${stats.BWS.kills}\``, true)
329 .addField("**Wins:**", `\`${stats.BWS.wins}\``, true)
330 .setImage(stats.BWS.image)
331 pages.push(BWSEmbed);
332 }
333 if(stats.hasOwnProperty("SW")){
334 const SWEmbed = new Discord.RichEmbed()
335 .addField("**Points:**", `\`${stats.SW.points}\``, true)
336 .addField("**Played:**", `\`${stats.SW.played}\``, true)
337 .addField("**Deaths:**", `\`${stats.SW.deaths}\``, true)
338 .addField("**Kills:**", `\`${stats.SW.kills}\``, true)
339 .addField("**Wins:**", `\`${stats.SW.wins}\``, true)
340 .addBlankField(true)
341 .setImage(stats.SW.image)
342 pages.push(SWEmbed);
343 }
344 if(stats.hasOwnProperty("SWS")){
345 const SWSEmbed = new Discord.RichEmbed()
346 .addField("**Points:**", `\`${stats.SWS.points}\``, true)
347 .addField("**Played:**", `\`${stats.SWS.played}\``, true)
348 .addField("**Deaths:**", `\`${stats.SWS.deaths}\``, true)
349 .addField("**Kills:**", `\`${stats.SWS.kills}\``, true)
350 .addField("**Wins:**", `\`${stats.SWS.wins}\``, true)
351 .addBlankField(true)
352 .setImage(stats.SWS.image)
353 pages.push(SWSEmbed);
354 }
355 if(stats.hasOwnProperty("GNT")){
356 const GNTEmbed = new Discord.RichEmbed()
357 .addField("**Points:**", `\`${stats.GNT.points}\``, true)
358 .addField("**Played:**", `\`${stats.GNT.played}\``, true)
359 .addField("**Deaths:**", `\`${stats.GNT.deaths}\``, true)
360 .addField("**Kills:**", `\`${stats.GNT.kills}\``, true)
361 .addField("**Wins:**", `\`${stats.GNT.wins}\``, true)
362 .addBlankField(true)
363 .setImage(stats.GNT.image)
364 pages.push(GNTEmbed);
365 }
366 if(stats.hasOwnProperty("GNTM")){
367 const GNTMEmbed = new Discord.RichEmbed()
368 .addField("**Points:**", `\`${stats.GNTM.points}\``, true)
369 .addField("**Played:**", `\`${stats.GNTM.played}\``, true)
370 .addField("**Deaths:**", `\`${stats.GNTM.deaths}\``, true)
371 .addField("**Kills:**", `\`${stats.GNTM.kills}\``, true)
372 .addField("**Wins:**", `\`${stats.GNTM.wins}\``, true)
373 .addBlankField(true)
374 .setImage(stats.GNTM.image)
375 pages.push(GNTMEmbed);
376 }
377 if(stats.hasOwnProperty("TB")){
378 const TBEmbed = new Discord.RichEmbed()
379 .addField("**Points:**", `\`${stats.TB.points}\``, true)
380 .addField("**Played:**", `\`${stats.TB.played}\``, true)
381 .addField("**Deaths:**", `\`${stats.TB.deaths}\``, true)
382 .addField("**Goals:**", `\`${stats.TB.goals}\``, true)
383 .addField("**Kills:**", `\`${stats.TB.kills}\``, true)
384 .addField("**Wins:**", `\`${stats.TB.wins}\``, true)
385 .setImage(stats.TB.image)
386 pages.push(TBEmbed);
387 }
388 if(stats.hasOwnProperty("oneVSone")){
389 const oneVSoneEmbed = new Discord.RichEmbed()
390 .addField("**Points:**", `\`${stats.oneVSone.points}\``, true)
391 .addField("**Played:**", `\`${stats.oneVSone.played}\``, true)
392 .addField("**Deaths:**", `\`${stats.oneVSone.deaths}\``, true)
393 .addField("**Rounds:**", `\`${stats.oneVSone.rounds}\``, true)
394 .addField("**Kills:**", `\`${stats.oneVSone.kills}\``, true)
395 .addField("**Wins:**", `\`${stats.oneVSone.wins}\``, true)
396 .setImage(stats.oneVSone.image)
397 pages.push(oneVSoneEmbed);
398 }
399 pages.forEach((e, i)=>{
400 e.fields.forEach((f, fi)=>{
401 if(e.fields.length === fi+1){
402 if(f.value === "\`NaN\`"){
403 pages.splice(i,1);
404 };
405 };
406 });
407 });
408
409 setTimeout(()=>{
410 if(pages.length !== 1){
411 pages.forEach(e=>{
412 e.setColor(userHexColor);
413 e.setFooter(`Page ${page+1} of ${pages.length} | Made by: .MohamedTarek#9258`);
414 if(e.author === embed.author) return;
415 e.setTitle(`${userName}'s Games Stats ? `);
416 });
417 }
418
419 var hhh = 0;
420 var hoho = 0;
421 if (isNaN(page)) {
422 hhh = 1
423 hoho = 0} else if (page > pages.length || page < 0 ) {return message.channel.send('There\'s no such page!')} else {hhh = page
424 hoho = page-1}
425 console.log(hhh)
426 pages[hoho].setFooter(`Page ${hhh} of ${pages.length} looool| Made by: .MohamedTarek#9258`);
427 if (talkedRecently.has(msg.author.id)) {
428 return msg.channel.send("Wait 5 sec before getting typing this again.");
429 } else {
430 talkedRecently.add(msg.author.id);
431 setTimeout(() => {
432 talkedRecently.delete(msg.author.id);
433 }, 5000);
434 }
435 message.channel.send(pages[hoho]).then(embedmsg=>{
436 message.channel.stopTyping(true);
437 if(pages.length === 1) return;
438 embedmsg.react("◀").then(()=>{
439 embedmsg.react("▶").then(()=>{
440 const backwardsFilter = (reaction, user) => reaction.emoji.name === '◀' && user.id === message.author.id;
441 const forwardsFilter = (reaction, user) => reaction.emoji.name === '▶' && user.id === message.author.id;
442 const backwards = embedmsg.createReactionCollector(backwardsFilter, {time: 120000});
443 const forwards = embedmsg.createReactionCollector(forwardsFilter, {time: 120000});
444 backwards.on("collect", r=>{
445 r.remove(message.author);
446 if(hoho === 0) return;
447 hhh--;
448 hoho--;
449 pages[hoho].setFooter(`Page ${hhh} of ${pages.length} | Made by: .MohamedTarek#9258`);
450 embedmsg.edit(pages[hoho]);
451 });
452 forwards.on("collect", r=>{
453 r.remove(message.author);
454 if(hoho+1 === pages.length) return;
455 hhh++;
456 hoho++;
457 pages[hoho].setFooter(`Page ${hhh} of ${pages.length} | Made by: .MohamedTarek#9258`);
458 embedmsg.edit(pages[hoho]);
459 });
460 });
461 });
462 });
463 }, 250);
464 };
465 });
466 }else{
467 return message.channel.send("There might be an error with the API or the name is incorrect")
468 }
469 });
470 };
471 if(cmd === `${prefix}history`){
472 let player = args.slice(0).join(" ");
473 if (!player) return message.channel.send(`**Usage: \`${prefix}history <Player Name>\`**`);
474
475 getJSON(`https://api.mojang.com/users/profiles/minecraft/${player}`, function(error, response){
476 if (error) {
477 return message.channel.send('There seems to be an error with the API. Try again later. :confounded:');
478 } else {
479 var uuid = response.id;
480
481 getJSON(`https://api.mojang.com/user/profiles/${uuid}/names`, function(error, response){
482 var x = 1;
483 var new_arr = response.reverse();
484 const embed = new Discord.RichEmbed()
485 .addField(`${player} past names`, new_arr.map(m => `${x++} \`${m['name']}\``), true);
486 message.channel.send(embed);
487 });
488 }
489 });
490 }
491 if(cmd === `${prefix}about`){
492 let node = client.guilds.get("565898198279913473").emojis.get("611436703869304844");
493 let invite = `https://discordapp.com/oauth2/authorize?&client_id=${client.user.id}&scope=bot&permissions=12659727`;
494 let delta = client.uptime;
495 var days = Math.floor(delta / 86400);
496 delta -= days * 86400;
497 var hours = Math.floor(delta / 3600) % 24;
498 delta -= hours * 3600;
499 var minutes = Math.floor(delta / 60) % 60;
500 delta -= minutes * 60;
501 var total = `${days}:${hours}:${minutes}`;
502 let ping = Date.now() - msg.createdTimestamp;
503 const embed = new Discord.RichEmbed()
504 .setTitle(`:bar_chart: BlocksMC Players Bot`)
505 .setDescription(`**[Support Team](https://discord.gg/p7krJgj)** | **[Invite](${invite})**\n\n${node.toString()} Node.js version: **${Number(process.version.match(/^v(\d+\.\d+)/)[1])}**\n:clock1230: Uptime: **${total}**\n:stopwatch: Average Ping: **${ping} ms**\n:file_cabinet: Total Servers: **${client.guilds.size}**\n:busts_in_silhouette: Total Users: **${client.users.size}**`)
506 .setFooter(`Requested by ${msg.author.username}#${msg.author.discriminator}`, msg.author.avatarURL)
507 .setTimestamp();
508 msg.channel.send(embed);
509 }
510 if(cmd === `${prefix}invite`){
511 let invite = `https://discordapp.com/oauth2/authorize?&client_id=${client.user.id}&scope=bot&permissions=12659727`;
512 msg.author.send(invite);
513 msg.reply("تم ارسال رابط دعوة البوت الى خاصك");
514 }
515 if(cmd === `${prefix}help`){
516let replies = [
517 "**b$blocks** **-**في هذا الأمر يمكنك من رؤية معلومات واحصائيات اي لاعب في بلوكس",
518 "**b$skin** **-** في هذا الأمر يمكنك من رؤية سكن اي لاعب تكتبه ",
519 "**b$history** **-** في هذا الأمر يمكنك رؤية تاريخ الاسماء لأي لاعب تكتبه",
520 "**b$suggest** **-** في هذا الأمر يمكنك ارسال اقتراح لمبرمجين البوت",
521 "**b$invite** **-** في هذا الأمر يمكنك الحصول على رابط دعوة البوت",
522 "**b$about** **-** في هذا الأمر يمكنك رؤية معلومات واحصائيات عن البوت "
523]
524let replies2 =
525[
526 "**b$blocks** **-** You can see Info and stats about any player in blocksmc",
527 "**b$skin** **-** You can see the skin of any player you type",
528 "**b$history** **-** You can see the name history of anybody you want",
529 "**b$suggest** **-** You can send your suggestions using this command",
530 "**b$invite** **-** You can get the bot invite using this command",
531 "**b$about** **-** You can learn about the bot and it's stats using this command"
532
533
534]
535var Embed = new Discord.RichEmbed()
536.setTitle("BlocksMC Community")
537.setAuthor("BlocksMC", `https://cdn.discordapp.com/emojis/444254912491290624.png?v=1%22`)
538.addField("__**الأوامر**__", replies)
539.addField("__**Commands**__", replies2)
540.setURL(`https://blocksmc.com/`)
541.setThumbnail("https://cdn.discordapp.com/emojis/444254912491290624.png?v=1%22")
542.setFooter("Developed By: .MohamedTarek#9258")
543message.channel.send(Embed)
544}
545
546
547
548 if(cmd === `${prefix}suggest`) {
549let suggestionchat = bot.guilds.get("565898198279913473").channels.get("595793620276346880")
550let suggestion = args.join(' ');
551
552if(!suggestion) return message.channel.send('الرجاء وضع اقتراحك بعد الأمر');
553if(!suggestionchat) return message.channel.send('There seems to be an error Please Contact the developers of the bot');
554
555let suggestionembed = new Discord.RichEmbed()
556 .setAuthor('New Suggestion!', 'https://cdn.discordapp.com/emojis/444254912491290624.png?v=1%22)')
557 .addField('Suggestion By', `${message.author.tag} **|** ${message.author.id}`, true)
558 .addField('Server name', `${message.guild.name} **|** ${message.guild.id}`)
559 .addField('Suggestion', `${suggestion}`)
560 .setColor('#ffffff')
561 .setTimestamp();
562suggestionchat.send(suggestionembed);
563
564message.channel.send("Done =) Your suggestion has been sent to the developers")
565 }
566
567if(cmd === `${prefix}skin`){
568 if (message.author.id === bot.user.id) return;
569
570 let player = args.slice(0).join(" ");
571 if (!player) return message.channel.send('الرجاء وضع اسم اللاعب')
572
573
574 getJSON(`https://api.mojang.com/users/profiles/minecraft/${player}`, function(error, response){
575 if (error) {
576 return message.channel.send('There seems to be an error with the API. Try again later. :confounded:');
577 } else {
578 var uuid = response.id;
579
580 const options = {
581 url: `https://visage.surgeplay.com/full/250/${uuid}.png`,
582 dest: `./${uuid}.png`
583 };
584 download.image(options)
585 .then(({ filename, image }) => {
586 console.log('File saved to', filename);
587 })
588 .catch((err) => {
589 console.error(err);
590 });
591
592 setTimeout(() => {
593 var embed = new Discord.RichEmbed()
594 .setTitle(player)
595 .setColor("#ffffff")
596 .setFooter("Made by: .MohamedTarek#9258")
597 .attachFiles([`${__dirname}/${uuid}.png`])
598 .setImage(`attachment://${uuid}.png`)
599 .setThumbnail(`https://visage.surgeplay.com/head/${uuid}?size=30`)
600 .setURL(`https://namemc.com/profile/${player}`)
601 .addBlankField(true);
602 message.channel.send(embed);
603 }, 2000);
604 }
605 setTimeout(() => {
606 fs.unlink(`./${uuid}.png`, function(error) {
607 if (error) {
608 console.log(error);
609 }
610 });
611 }, 5000);
612 });
613 }else{
614 return;
615 }
616
617})