Advertisement
Guest User

credit

a guest
Feb 23rd, 2019
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.33 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. const prefix = "!"
  4.  
  5.  
  6. client.on('message', message => {
  7.  
  8. if(message.content.startsWith(prefix + 'rep')) {
  9. if(!message.channel.guild) return;
  10. moment.locale('en');
  11. var getvalueof = message.mentions.users.first()
  12. if(!getvalueof) return message.channel.send(`**:mag: | ${message.author.username}, the user could not be found. **`);
  13. if(getvalueof.id == message.author.id) return message.channel.send(`**${message.author.username}, you cant give yourself a reputation !**`)
  14. if(profile[message.author.id].reps != moment().format('L')) {
  15. profile[message.author.id].reps = moment().format('L');
  16. profile[getvalueof.id].rep = Math.floor(profile[getvalueof.id].rep+1);
  17. message.channel.send(`** :up: | ${message.author.username} has given ${getvalueof} a reputation point!**`)
  18. } else {
  19. message.channel.send(`**:stopwatch: | ${message.author.username}, you can raward more reputation ${moment().endOf('day').fromNow()} **`)
  20. }
  21. }
  22. fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  23. if (err) console.error(err);
  24. })
  25. });
  26.  
  27. client.on("message", (message) => {
  28. let men = message.mentions.users.first()
  29.  
  30. if (message.author.bot) return;
  31. if (message.author.id === client.user.id) return;
  32. if(!message.channel.guild) return;
  33. if (message.content.startsWith(prefix + 'credit')) {
  34. if(men) {
  35. if (!profile[men.id]) profile[men.id] = {
  36. lastDaily:'Not Collected',
  37. credits: 1,
  38. };
  39. }
  40. if(men) {
  41. message.channel.send(`** ${men.username}, :credit_card: balance` + " is `" + `${profile[men.id].credits}$` + "`.**")
  42. } else {
  43. message.channel.send(`** ${message.author.username}, your :credit_card: balance` + " is `" + `${profile[message.author.id].credits}$` + "`.**")
  44. }
  45. }
  46.  
  47. if(message.content.startsWith(prefix + "daily")) {
  48. if(profile[message.author.id].lastDaily != moment().format('day')) {
  49. profile[message.author.id].lastDaily = moment().format('day')
  50. profile[message.author.id].credits += 200
  51. message.channel.send(`**${message.author.username} you collect your \`200\` :dollar: daily pounds**`)
  52. } else {
  53. message.channel.send(`**:stopwatch: | ${message.author.username}, your daily :yen: credits refreshes ${moment().endOf('day').fromNow()}**`)
  54. }
  55. }
  56.  
  57.  
  58. let cont = message.content.slice(prefix.length).split(" ");
  59. let args = cont.slice(1);
  60. let sender = message.author
  61. if(message.content.startsWith(prefix + 'trans')) {
  62. if (!args[0]) {
  63. message.channel.send(`**Usage: ${prefix}trans @someone amount**`);
  64. return;
  65. }
  66. // We should also make sure that args[0] is a number
  67. if (isNaN(args[0])) {
  68. message.channel.send(`**Usage: ${prefix}trans @someone amount**`);
  69. return; // Remember to return if you are sending an error message! So the rest of the code doesn't run.
  70. }
  71. let defineduser = '';
  72. let firstMentioned = message.mentions.users.first();
  73. defineduser = (firstMentioned)
  74. if (!defineduser) return message.channel.send(`**Usage: ${prefix}trans @someone amount**`);
  75. var mentionned = message.mentions.users.first();
  76. if (!profile[sender.id]) profile[sender.id] = {}
  77. if (!profile[sender.id].credits) profile[sender.id].credits = 200;
  78. fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  79. if (err) console.error(err);
  80. })
  81. var mando = message.mentions.users.id;
  82. if (!profile[defineduser.id]) profile[defineduser.id] = {}
  83. if (!profile[defineduser.id].credits) profile[defineduser.id].credits = 200;
  84. profile[defineduser.id].credits += (+args[0]);
  85. profile[sender.id].credits += (-args[0]);
  86. let mariam = message.author.username
  87. message.channel.send(`**:moneybag: | ${message.author.username}, has transferrerd ` + "`" + args[0] + "$` to " + `<@${defineduser.id}>**`)
  88. }
  89.  
  90. });
  91.  
  92. client.on('message', message => {
  93. if(!profile[message.author.id]) profile[message.author.id] ={
  94. points: 0,
  95. level: 1
  96. };
  97. if(message.author.bot) return;
  98. profile[message.author.id].points = Math.floor(profile[message.author.id].points+1);
  99. if(profile[message.author.id].points > 100) {
  100. profile[message.author.id].points = 0
  101. profile[message.author.id].level = Math.floor(profile[message.author.id].level+1);
  102. message.channel.send(`**${message.author.username}, You leveld up to __${profile[message.author.id].level}__**`)
  103. }
  104. fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  105. if (err) console.error(err);
  106. })
  107. })
  108.  
  109. client.on('message', message => {
  110. let tit = message.content.split(" ").slice(1).join(" ");
  111. if(message.content.startsWith(prefix + "title")) {
  112. if(!profile[message.author.id].tite) profile[message.author.id].tite = "Hey im using Super"
  113. if(!tit) {
  114. message.channel.send("**Usage: <title <something>**");
  115. } else {
  116. profile[message.author.id].tite = tit
  117. message.channel.send(`:ok:`)
  118. }
  119. }
  120. fs.writeFile('profile.json', JSON.stringify(profile), (err) => {
  121. if (err) console.error(err);
  122. })
  123. })
  124.  
  125. client.on("message", message => {
  126. if (message.author.bot) return;
  127. if(!message.channel.guild) return;
  128. if (message.content.startsWith(prefix + "profile")) {
  129. let user = message.mentions.users.first();
  130. var men = message.mentions.users.first();
  131. var heg;
  132. if(men) {
  133. heg = men
  134. } else {
  135. heg = message.author
  136. }
  137. var mentionned = message.mentions.members.first();
  138. var h;
  139. if(mentionned) {
  140. h = mentionned
  141. } else {
  142. h = message.member
  143. }
  144. var ment = message.mentions.users.first();
  145. var getvalueof;
  146. if(ment) {
  147. getvalueof = ment;
  148. } else {
  149. getvalueof = message.author;
  150. }
  151. var mentionned = message.mentions.users.first();
  152.  
  153. var client;
  154. if(mentionned){
  155. var client = mentionned;
  156. } else {
  157. var client = message.author;
  158.  
  159. }
  160. if (!profile[getvalueof.id]) profile[getvalueof.id] = {points: 0,reps: "NOT YET",credits: 1, level: 1,tite: "HypeLC User", rep: 0, lastDaily: "NOT COLLECTED"};
  161. let Image = Canvas.Image,
  162. canvas = new Canvas(300, 300),
  163. ctx = canvas.getContext('2d');
  164. fs.readFile("Super.png", function (err, Background) { //امتداد الصورة
  165. if (err) return console.log(err);
  166. let BG = Canvas.Image;
  167. let ground = new Image;
  168. ground.src = Background;
  169. ctx.drawImage(ground, 0, 0, 300, 300); // حجم الصورة
  170.  
  171. })
  172.  
  173.  
  174.  
  175. let url = getvalueof.displayAvatarURL.endsWith(".webp") ? getvalueof.displayAvatarURL.slice(5, -20) + ".png" : getvalueof.displayAvatarURL;
  176. jimp.read(url, (err, ava) => {
  177. if (err) return console.log(err);
  178. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  179. if (err) return console.log(err);
  180.  
  181. //ur name
  182. ctx.font = 'bold 16px kathen'; // حجم الخط و نوعه
  183. ctx.fontSize = '40px'; // عرض الخط
  184. ctx.fillStyle = "#000000"; // لون الخط
  185. ctx.textAlign = "center"; // محاذا ة النص
  186. ctx.fillText(`${getvalueof.username}`, 153, 173) // احداثيات اسمك
  187.  
  188. //ur name
  189. ctx.font = 'bold 16px kathen'; // حجم الخط و نوعه
  190. ctx.fontSize = '40px'; // عرض الخط
  191. ctx.fillStyle = "#f1f1f1"; // لون الخط
  192. ctx.textAlign = "center"; // محاذا ة النص
  193. ctx.fillText(`${getvalueof.username}`, 151, 171) // احداثيات اسمك
  194.  
  195. //credit
  196. ctx.font = "bold 12px kathen" // نوع الخط وحجمه
  197. ctx.fontSize = '10px'; // عرض الخط
  198. ctx.fillStyle = "#f1f1f1" // لون الخط
  199. ctx.textAlign = "center"; // محاذا ة النص
  200. ctx.fillText(`$${profile[getvalueof.id].credits}`, 81, 159) // احداثيات المصاري
  201.  
  202. //poits
  203. ctx.font = "bold 12px kathen" // ن
  204. ctx.fontSize = '10px'; // عرض الخطوع الخط وحجمه
  205. ctx.fillStyle = "#f1f1f1" // لون الخط
  206. ctx.textAlign = "center"; // محاذا ة النص
  207. ctx.fillText(`${profile[getvalueof.id].points}`, 221, 159) // احداثيات النقاط
  208.  
  209. //Level
  210. ctx.font = "bold 27px kathen" // نوع الخط و حجمه
  211. ctx.fontSize = '10px'; // عرض الخط
  212. ctx.fillStyle = "#f1f1f1" // لون الخط
  213. ctx.textAlign = "center"; // محاذا ة النص
  214. ctx.fillText(`${profile[getvalueof.id].level}`, 221, 118) // احداثيات اللفل
  215.  
  216. //info
  217. ctx.font = "bold 12px kathen" // ن
  218. ctx.fontSize = '15px'; // عرض الخطوع الخط وحجمه
  219. ctx.fillStyle = "#000000" // لون الخط
  220. ctx.textAlign = "center"; // محاذا ة النص
  221. ctx.fillText(`${profile[getvalueof.id].tite}`, 150, 199) // احداثيات النقاط
  222.  
  223. //info
  224. ctx.font = "bold 12px kathen" // ن
  225. ctx.fontSize = '15px'; // عرض الخطوع الخط وحجمه
  226. ctx.fillStyle = "#f1f1f1" // لون الخط
  227. ctx.textAlign = "center"; // محاذا ة النص
  228. ctx.fillText(`${profile[getvalueof.id].tite}`, 150, 197) // احداثيات النقاط
  229.  
  230. // REP
  231. ctx.font = "bold 26px kathen";
  232. ctx.fontSize = "50px";
  233. ctx.fillStyle = "#f1f1f1";
  234. ctx.textAlign = "center";
  235. ctx.fillText(`+${profile[getvalueof.id].rep}`, 80,117)
  236.  
  237. let Avatar = Canvas.Image;
  238. let ava = new Avatar;
  239.  
  240. ava.src = buf;
  241. ctx.beginPath();
  242. ctx.arc(75, 100, 780, 0, Math.PI*2, true);
  243. ctx.closePath();
  244. ctx.clip();
  245. ctx.drawImage(ava, 116, 82, 72, 72);
  246.  
  247. message.channel.startTyping()
  248. message.channel.sendFile(canvas.toBuffer())
  249. message.channel.stopTyping()
  250. })
  251. })
  252. }
  253. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement