Guest User

Untitled

a guest
Sep 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. const Discord = require("discord.js"); // بكج
  2. const bot = new Discord.Client({disableEveryone: true});
  3. const Canvas = require('canvas') // بكج
  4. const fs = module.require("fs"); //بكج
  5. const r1 = require('snekfetch'); //بكج
  6.  
  7.  
  8. //var يعني تختصر للحاجه زي منا عامل كدة
  9.  
  10. var copy = "s2ud | 502#0150"
  11.  
  12.  
  13. var mo = "الفلوس"
  14. var po = "النقاط"
  15. var lev = "الفل"
  16.  
  17.  
  18. bot.on("ready", async () => { // كل حاجه هتتفح لما البوت يشتغل
  19.  
  20. console.log(`I'm Online \n By ${copy}`) // الي هيظهر في الكونسل
  21. console.log(`Logged in as ${bot.user.tag}!`); // نفس الي فوق
  22.  
  23. bot.user.setGame(`${bot.users.size} users `,"http://twitch.tv/") // الي هيظهر في بلاينق
  24. bot.user.setStatus("online") // حاله البوت (اونلاين
  25.  
  26. }); // نهايه الكود
  27.  
  28.  
  29.  
  30. bot.on('message', message => {
  31.  
  32. if (message.content.startsWith("$profile")) { // الامر
  33. let canvas = new Canvas(300, 300) //حجم الصوره الي هتظهر
  34. let ctx = canvas.getContext('2d')
  35. let Image = Canvas.Image
  36.  
  37.  
  38. // ava.src = buf;
  39.  
  40. fs.readFile(__dirname + '/images_profile/profile.png', function(err, picture) { //مكان الصوره
  41. if (err) throw err
  42. var img = new Image
  43. var url = message.author.avatarURL; //افتار صورتك
  44. url = url.substring(0, url.indexOf('?'));
  45.  
  46. r1.get(url).then(res => {
  47. var dataURL = res.body.toString('base64');
  48. dataURL = 'data:image/png;base64,' + dataURL;
  49. img.onload = function() {
  50.  
  51. ctx.save();
  52. ctx.beginPath();
  53. ctx.arc(54, 103, 47, 0, Math.PI * 2, true); // احدثيات الدائره
  54. ctx.closePath();
  55. ctx.clip();
  56. ctx.drawImage(img, 8, 57, 92, 92); // الصوره
  57. ctx.restore();
  58. }
  59. img.src = dataURL;
  60. });
  61.  
  62. img.onload = () => {
  63. ctx.drawImage(img, 1, 1, 300, 300)
  64. // ctx.drawImage(message.author.avatarURL, 152, 27, 95, 95);
  65. ctx.font = "regular 11px Cairo" // نوع الخط وحجمه
  66. ctx.fillStyle = "#9f9f9f" // لون الخط
  67. ctx.fillText(`${message.author.username}`, 140, 137)
  68. ctx.fillText(`${mo} `, 143, 219) //money
  69. ctx.fillText(`${po}`, 120, 202) // النقاط
  70.  
  71. //Level
  72. ctx.font = "regular 21px Cairo"
  73. ctx.fillStyle = "#ffffff"
  74. ctx.fillText(`${lev}`, 47, 255) //لفل
  75.  
  76. ctx.save()
  77.  
  78. }
  79. img.src = picture
  80.  
  81. })
  82.  
  83.  
  84.  
  85.  
  86.  
  87. setTimeout(function() {
  88. fs.readFile(__dirname + '/images_profile/diamond_prof_bg.png', function(err, picture) {
  89. if (err) throw err
  90. var img = new Image
  91. img.onload = () => {
  92. ctx.drawImage(img, -1, -1, 0, 0)
  93. }
  94. img.src = picture
  95. let inventoryPicture = canvas.toDataURL()
  96. let data = inventoryPicture.replace(/^data:image\/\w+;base64,/, "")
  97. let buf = new Buffer(data, 'base64')
  98. fs.writeFile(`image.png`, buf)
  99.  
  100. message.channel.send("", {
  101. file: `image.png`
  102. })
  103. })
  104. }, 1000)
  105.  
  106.  
  107. function roundedImage(x, y, width, height, radius) {
  108. ctx.beginPath();
  109. ctx.moveTo(x + radius, y);
  110. ctx.lineTo(x + width - radius, y);
  111. ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
  112. ctx.lineTo(x + width, y + height - radius);
  113. ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  114. ctx.lineTo(x + radius, y + height);
  115. ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
  116. ctx.lineTo(x, y + radius);
  117. ctx.quadraticCurveTo(x, y, x + radius, y);
  118. ctx.closePath();
  119. }
  120.  
  121. function wrapText(context, text, x, y, maxWidth, lineHeight) {
  122.  
  123. var words = text.split(' '),
  124. line = '',
  125. lineCount = 0,
  126. i,
  127. test,
  128. metrics;
  129.  
  130. for (i = 0; i < words.length; i++) {
  131. test = words[i];
  132. metrics = context.measureText(test);
  133. while (metrics.width > maxWidth) {
  134.  
  135. test = test.substring(0, test.length - 1);
  136. metrics = context.measureText(test);
  137. }
  138. if (words[i] != test) {
  139. words.splice(i + 1, 0, words[i].substr(test.length))
  140. words[i] = test;
  141. }
  142.  
  143. test = line + words[i] + ' ';
  144. metrics = context.measureText(test);
  145.  
  146. if (metrics.width > maxWidth && i > 0) {
  147. context.fillText(line, x, y);
  148. line = words[i] + ' ';
  149. y += lineHeight;
  150. lineCount++;
  151. } else {
  152. line = test;
  153. }
  154. }
  155.  
  156. ctx.fillText(line, x, y);
  157. }
  158.  
  159.  
  160.  
  161.  
  162. };
  163.  
  164.  
  165.  
  166.  
  167. });
Add Comment
Please, Sign In to add comment