Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.92 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. var prefix=`!`
  4. const moment = require('moment');
  5. const fs = require('fs');
  6. var version = '11.0.0';
  7. var owner = 'owner id'
  8. const Bot = new Discord.Client();
  9.  
  10. let daily = JSON.parse(fs.readFileSync("./daily.json", "utf8")); // يقرا ملف jso
  11. let rep = JSON.parse(fs.readFileSync("./rep.json", "utf8"));
  12.  
  13. const sql = require("sqlite");
  14. sql.open("./score.sqlite");
  15.  
  16. client.on("message", message => {
  17. if(!daily[message.author.id]) {
  18. daily[message.author.id] = {
  19. getDaily: false,
  20. dayClaimed: ''
  21. }
  22. }
  23. let conf = daily[message.author.id];
  24.  
  25. if (message.author.bot) return;
  26. if (message.channel.type !== "text") return;
  27.  
  28. sql.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
  29. if (!row) {
  30. sql.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 2, 0]);
  31. } else {
  32. let curLevel = Math.floor(0.2 * Math.sqrt(row.points + 1));
  33. if (curLevel > row.level) {
  34. row.level = curLevel;
  35. sql.run(`UPDATE scores SET points = ${row.points + 1}, level = ${row.level} WHERE userId = ${message.author.id}`);
  36.  
  37. var Canvas = require('canvas')
  38. var jimp = require('jimp')
  39. const w = ['./img/up1.png','./img/up2.png','./img/up.png'];
  40.  
  41. let Image = Canvas.Image,
  42. canvas = new Canvas(88, 110),
  43. Ui = canvas.getContext('2d');
  44. Ui.patternQuality = 'bilinear';
  45. Ui.filter = 'bilinear';
  46. Ui.antialias = 'subpixel';
  47. Ui.shadowColor = 'rgba(0, 0, 0, 0.4)';
  48. Ui.shadowOffsetY = 2;
  49. Ui.shadowBlur = 2;
  50. fs.readFile(`${w[Math.floor(Math.random() * w.length)]}`, function (err, Background) {
  51. if (err) return console.log(err);
  52. let BG = Canvas.Image;
  53. let ground = new BG;
  54. ground.src = Background;
  55. Ui.drawImage(ground, 0, 0, 88, 110); // 0, 0, 207, 176
  56.  
  57. })
  58.  
  59. let url = message.author.displayAvatarURL.endsWith(".webp") ? message.author.displayAvatarURL.slice(5, -20) + ".gif" : message.author.displayAvatarURL;
  60. jimp.read(url, (err, ava) => {
  61. if (err) return console.log(err);
  62. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  63. if (err) return console.log(err);
  64. let Avatar = Canvas.Image;
  65. /* Ui.arc(80,80,50,0,2*Math.PI);
  66. Ui.clip();*/
  67. let ava = new Avatar;
  68. ava.src = buf;
  69. Ui.drawImage(ava, 19, 3, 52, 50);
  70. Ui.font = 'bold 30px Helvetica';
  71. Ui.fontSize = '30px';
  72. Ui.fillStyle = "#c4bdbd";
  73. Ui.textAlign = "center";
  74. Ui.fillText(`${row.level}`, 45, 105);
  75. message.channel.send(`:up: ** | ${message.author.username} Level Up! To ${row.level} ** `, {file: canvas.toBuffer()});
  76. });
  77. });
  78. }
  79. sql.run(`UPDATE scores SET points = ${row.points + 1} WHERE userId = ${message.author.id}`);
  80. }
  81. }).catch(() => {
  82. console.error;
  83. sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, points INTEGER, level INTEGER)").then(() => {
  84. sql.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 1, 1]);
  85. });
  86. });
  87.  
  88. if (!message.content.startsWith(prefix)) return;
  89.  
  90. if (message.content.startsWith(prefix + "لفل")) {
  91. if(!message.channel.guild) return;
  92. sql.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
  93. if (!row) return message.reply("Your current level is 0");
  94. const embed32 = new Discord.RichEmbed()
  95. .setAuthor(` `,client.user.avatarURL)
  96. .setColor("GRAY")
  97. .setAuthor(message.user.displayAvatarURL)
  98.  
  99. .addField("**Level:**",`${row.level}`,true)
  100. .setFooter(`${prefix}ترتيبك || `)
  101. message.reply("Your Level");
  102. message.channel.sendEmbed(embed32);
  103. console.log('[level] Send By: ' + message.author.username)
  104. });
  105. }
  106.  
  107. if (message.content.startsWith(prefix + "هدية")) {
  108. if(!message.channel.guild) return message.reply('** This command only for servers**');
  109. sql.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
  110. if (!row) return message.reply("sadly you do not have any points yet!");
  111. sql.run(`UPDATE scores SET points = ${row.points + 500} WHERE userId = ${message.author.id}`);
  112. if(conf.getDaily == false) {
  113. row.points + '500';
  114. message.channel.send(` **:ballot_box_with_check: | ${message.author.username} , You Have Add ${'`500$`'} to your account :credit_card: **`)
  115. conf.getDaily = true;
  116. const d = new Date();
  117. const day = d.getDate()
  118. conf.dayClaimed = day;
  119. } else {
  120. sql.run(`UPDATE scores SET points = ${row.points + 0} WHERE userId = ${message.author.id}`);
  121. message.channel.send(` **⏰ | ${message.author.username} , To get Agin come back ${moment().endOf('day').fromNow()}**`);
  122. }
  123.  
  124. const d = new Date();
  125. const day = d.getDate();
  126.  
  127. if(conf.dayClaimed + 1) {
  128. conf.getDaily = true;
  129. }
  130.  
  131. // نجرب ض1؟
  132. message.react("💳")
  133.  
  134. });
  135. }
  136.  
  137. if(message.content.startsWith(prefix+'تشفير')){
  138. // if(!message.channel.guild) return message.reply('** This command only for servers**');
  139. const hex = require('hex.js');
  140. const args = message.content.split(' ').slice(1).join(' ');
  141. message.channel.send('تم التشفير: '+hex.hex(args));
  142. }
  143.  
  144. if(message.content.startsWith(prefix+'فك')){
  145. if(!message.channel.guild) return message.reply('** This command only for servers**');
  146. const hex = require('hex.js');
  147. const args = message.content.split(' ').slice(1).join(' ');
  148.  
  149. message.channel.send('تم فك التشفير: '+hex.unHex(args));
  150.  
  151. }
  152.  
  153.  
  154.  
  155. if (message.content.startsWith(prefix + "فلوس")) {
  156. if(!message.channel.guild) return;
  157. var ment = message.mentions.members.first();
  158. var getvalueof;
  159. if(ment) {
  160. getvalueof = ment;
  161. } else {
  162. getvalueof = message.author;
  163. }
  164. sql.get(`SELECT * FROM scores WHERE userId ="${getvalueof.id}"`).then(row => {
  165. if (!row) return message.reply("sadly you do not have any points yet!");
  166. message.channel.send(getvalueof.toString()+',** your :credit_card: balance is '+'`$'+`${row.points}`+'`**');
  167. console.log('[credit] Send By: ' + message.author.username)
  168. });
  169. }
  170. fs.writeFile("./daily.json", JSON.stringify(daily), (err) => {
  171. if (err) console.error(err)
  172. });
  173. });
  174.  
  175.  
  176.  
  177.  
  178.  
  179. client.pointsMonitor = (dateformat, message) => {
  180. if (message.channel.type !=='text') return;
  181. const settings = client.settings.get(message.guild.id);
  182. if (message.content.startsWith(settings.prefix)) return;
  183. const score = client.points.get(message.author.id) || { points: 1, level: 1 };
  184. score.points++;
  185. const curLevel = Math.floor(0.2 * Math.sqrt(score.points));
  186. if (score.level < curLevel) {
  187. message.channel.send(`حظا جيدا <@!${message.author.id}> لقد وصـلت الـى لفل ${curLevel} `);
  188. score.level = curLevel;
  189. }
  190. client.points.set(message.author.id, score);
  191. };
  192. let points = JSON.parse(fs.readFileSync("./points.json", "utf8"));
  193. client.on("message", message => {
  194. if (!message.content.startsWith(prefix)) return;
  195. if (message.author.bot) return;
  196.  
  197. if (!points[message.author.id]) points[message.author.id] = {
  198. points: 0,
  199. level: 0
  200. };
  201. let userData = points[message.author.id];
  202. userData.points++;
  203.  
  204. let curLevel = Math.floor(0.1 * Math.sqrt(userData.points));
  205. if (curLevel > userData.level) {
  206.  
  207. userData.level = curLevel;
  208. // message.reply(`You"ve leveled up to level **${curLevel}**! Ain"t that dandy?`);
  209. }
  210.  
  211. // if (message.content.startsWith(prefix + "level")) {
  212. //message.reply(`You are currently level ${userData.level}, with ${userData.points} points.`);
  213.  
  214. fs.writeFile("./points.json", JSON.stringify(points), (err) => {
  215. if (err) console.error(err)
  216. });
  217.  
  218. });
  219. client.on("message", message => {
  220. if(message.content.startsWith(prefix + 'ترتيبي')) {
  221. if(!message.channel.guild) return message.reply('** This command only for servers**');
  222. var ment = message.mentions.users.first();
  223. var getvalueof;
  224. if(ment) {
  225. getvalueof = ment;
  226. } else {
  227. getvalueof = message.author;
  228. }
  229. let userData = points[message.author.id];
  230. var Canvas = require('canvas')
  231. var jimp = require('jimp')
  232. const snumber = require('short-number')
  233. sql.get(`SELECT * FROM scores WHERE userId ="${getvalueof.id}"`).then(row => {
  234. message.channel.startTyping(1)
  235. const w = ['./img/rank.png'];
  236. let Image = Canvas.Image,
  237. canvas = new Canvas(360, 100),
  238. ctx = canvas.getContext('2d');
  239. ctx.patternQuality = 'bilinear';
  240. ctx.filter = 'bilinear';
  241. ctx.antialias = 'subpixel';
  242. ctx.shadowColor = 'rgba(0, 0, 0, 0.4)';
  243. ctx.shadowOffsetY = 2;
  244. ctx.shadowBlur = 2;
  245. fs.readFile(`${w[Math.floor(Math.random() * w.length)]}`, function (err, Background) {
  246. if (err) return console.log(err);
  247. let BG = Canvas.Image;
  248. let ground = new Image;
  249. ground.src = Background;
  250. ctx.drawImage(ground, 0, 0, 360, 100);
  251. });
  252. let url = getvalueof.displayAvatarURL.endsWith(".webp") ? getvalueof.displayAvatarURL.slice(5, -20) + ".png" : getvalueof.displayAvatarURL;
  253. jimp.read(url, (err, ava) => {
  254. if (err) return console.log(err);
  255. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  256. if (err) return console.log(err);
  257. let Avatar = Canvas.Image;
  258. let ava = new Avatar;
  259. ava.src = buf;
  260. ctx.drawImage(ava, 8, 7, 86, 86);
  261. if (!row) return message.reply("**Your Level Is 0 , Try .daily , Then Try This Command **");
  262. ctx.font = '20px Cairo';
  263. ctx.fontSize = '20px';
  264. ctx.fillStyle = "#FFFFFF";
  265. ctx.textAlign = "center";
  266. ctx.fillText(snumber(row.points), 263, 45);
  267. ctx.font = '20px Cairo';
  268. ctx.fontSize = '20px';
  269. ctx.fillStyle = "#FFFFFF";
  270. ctx.textAlign = "center";
  271. ctx.fillText(snumber(row.level), 135, 45);
  272. ctx.font = '20px Cairo';//xp
  273. ctx.fontSize = '28px';
  274. ctx.fillStyle = "#FFFFFF";
  275. ctx.textAlign = "center";
  276. ctx.fillText(userData.points, 330, 46);
  277. //Name
  278. ctx.font = "20px Cairo";
  279. ctx.fillStyle = "#FFFFFF";
  280. ctx.textAlign = "center";
  281. ctx.fillText(getvalueof.username, 240, 85);
  282.  
  283. message.channel.send(`**:pencil: | Here is ${getvalueof.username}'s Rank Card**`,{file : canvas.toBuffer()});
  284. message.channel.stopTyping(1)
  285. });
  286. });
  287. });
  288.  
  289.  
  290. console.log('rank is Using');
  291. }
  292.  
  293.  
  294. if(message.content.startsWith(prefix + 'العنوان')) {
  295. if(!message.channel.guild) return message.reply('** This command only for servers**');
  296. var args = message.content.split(" ").join(" ").slice(8)
  297. if (!args) return;
  298. db.updateText(`message_${message.author.id}`, args).then(i =>{
  299. message.channel.send(`Profile Message Changed To ${i.text}`)
  300. })
  301. }
  302.  
  303. if(!rep[message.author.id]) rep[message.author.id] = {
  304. reps: 'NOT YET',
  305. repo: 0,
  306. }
  307. if(message.content.startsWith(prefix + 'لايك')) {
  308. if(!message.channel.guild) return;
  309. moment.locale('ar');
  310. let ment = message.mentions.users.first();
  311. var getvalueof;
  312. if(ment) {
  313. getvalueof = ment;
  314. } else {
  315. getvalueof = message.author;
  316. }
  317. if(rep[message.author.id].reps != moment().format('L')) {
  318. rep[message.author.id].reps = moment().format('L');
  319. rep[getvalueof.id].repo += 1; // يضيف واحد كل مره يستخدم الامر ض1
  320. message.channel.send(`** :white_check_mark: | Successly Added To ${message.author} rep point ! **`)
  321. } else {
  322. const embed = new Discord.RichEmbed()
  323. .setTitle('خطأ!')
  324. .setColor('RED')
  325. .setDescription('**:alarm_clock: | لقد قمت بذالك بالفعل !, للإرسال مرة آخرى حاول ' + moment().endOf('day').fromNow().replace('in ', 'بعد ') + '**')
  326. message.channel.sendEmbed(embed);
  327. }
  328. }
  329.  
  330. fs.writeFile('./rep.json', JSON.stringify(rep), (err) => {
  331. if(err) throw err.message + ' '+err.file;
  332. })
  333. });
  334.  
  335. const db = require("quick.db");
  336. let dataPro = JSON.parse(fs.readFileSync('./walls.json', 'utf8'));
  337. client.on("message", message => {
  338. let args = message.content.split(' ').slice(1);
  339.  
  340. var prefix =`!`;
  341. let command = message.content.split(" ")[0];
  342. if (command === prefix + "تعيين") {
  343. if(!args[0]) return message.reply('يجب عليك اختيار رقم الخلفيه')
  344. if(dataPro[message.author.id].walls[args[0]]) {
  345. dataPro[message.author.id].ai = true;
  346. dataPro[message.author.id].wallSrc = dataPro[message.author.id].walls[args[0]].src;
  347. message.reply('تم بنجاح تغير الخلفيه');
  348. } else {
  349. message.reply('انت لا تملك هذه الخلفيه')
  350. }
  351. }
  352.  
  353. if(message.content.startsWith(prefix + 'خلفيات')) {
  354. var walls = dataPro[message.author.id].walls;
  355. for(var wall in walls) {
  356. console.log(walls[wall]);
  357. message.channel.send(walls[wall]);// ;(
  358. }
  359. }
  360. var wallpapers = {
  361. 1: {
  362. src: 'walls/1414.jpg',
  363. price: 1,
  364. },
  365. 2: {
  366. src: 'walls/1515.jpg',
  367. price: 2,
  368. },
  369. 3: {
  370. src: 'walls/7777.jpg',
  371. price: 3,
  372. },
  373. 4: {
  374. src: 'walls/9999.jpg',
  375. price: 4,
  376. },
  377. 5: {
  378. src: 'walls/44444.jpg',
  379. price: 5,
  380. },
  381. }
  382. if(!dataPro[message.author.id]) {
  383. dataPro[message.author.id] = {
  384. ai: false,
  385. wallSrc: './walls/default.jpg' ,
  386. walls: {}
  387. }
  388. }
  389. var prefix=`!`
  390. if(message.content.startsWith(prefix + 'شراء')) {
  391. sql.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
  392. if (!row) return message.reply("** Pls Try .daily And Try Agin**");
  393. if (!row) return message.reply("sadly you do not have any points yet!");
  394. let points = row.points;
  395. if(!args[0]) {
  396. let embed = new Discord.RichEmbed()
  397. .setDescription('**ورقم الخلفية .buy لـشراء خلفية آستخدم آمر ** ')
  398. .addField('Profile starwars','Price : $1000 Number: 1')
  399. .addField('Profile Sun','Preice: $1800 Number: 2')
  400. .addField('Profile Tree','Price : $2300 Number: 3')
  401. .addField('Profile Mount','Price: $3000 Number: 4')
  402. .addField('Profile Old Tree','Price: $4000 Number: 5')
  403. .setImage("");
  404. message.channel.send({embed: embed});
  405. } else {
  406.  
  407. if(wallpapers[args[0]].price > row.points) {
  408. message.reply('لا يمكنك شراء هذه الخلفيه لانك لا تملك المال الكافي لشرائها ')
  409. } else {
  410. if(dataPro[message.author.id].walls == wallpapers[args[0]]) return message.reply('انت تملك هذه الخلفيه مسبقاً');
  411. else {
  412. row.points - wallpapers[args[0]].price;
  413. sql.run(`UPDATE scores SET points = ${row.points - wallpapers[args[0]].price} WHERE userId = ${message.author.id}`);
  414. dataPro[message.author.id].ai = true;
  415. dataPro[message.author.id].walls[args[0]] = wallpapers[args[0]];
  416. message.reply('تم بنجاح شراء الخلفيه للاستخدام الخلفيه اكتب .set '+args[0]);
  417. }
  418.  
  419. }
  420.  
  421. }
  422.  
  423. });
  424. //message.reply('Hhihihi');
  425. }
  426.  
  427. fs.writeFile('./walls.json', JSON.stringify(dataPro), (err) => {
  428. if(err) console.log(err.message);
  429. })
  430. if(message.content.startsWith(prefix + 'بروفايل')) {
  431. if(!message.channel.guild) return message.reply('** This command only for servers**');
  432. var ment = message.mentions.users.first();
  433. var getvalueof;
  434. if(ment) {
  435. getvalueof = ment;
  436. } else {
  437. getvalueof = message.author;
  438. }
  439. if (!points[message.author.id]) points[message.author.id] = {
  440. points: 0,
  441. level: 0
  442. };
  443. let userData = points[message.author.id];
  444. userData.points++;
  445.  
  446. let curLevel = Math.floor(0.1 * Math.sqrt(userData.points));
  447. if (curLevel > userData.level) {
  448.  
  449. userData.level = curLevel;
  450. // message.reply(`You"ve leveled up to level **${curLevel}**! Ain"t that dandy?`);
  451. }
  452. var Canvas = require('canvas')
  453. var jimp = require('jimp')
  454. const snumber = require('short-number')
  455. sql.get(`SELECT * FROM scores WHERE userId ="${getvalueof.id}"`).then(row => {
  456. message.channel.startTyping(1)
  457. const w = ['./img/wall.png'];
  458. let Image = Canvas.Image,
  459. canvas = new Canvas(437, 437),
  460. ctx = canvas.getContext('2d');
  461. ctx.patternQuality = 'Cairo';
  462. ctx.filter = 'Cairo';
  463. ctx.antialias = 'Cairo';
  464. ctx.shadowColor = 'Cairo(0, 0, 0, 0.4)';
  465. ctx.shadowOffsetY = 2;
  466. ctx.shadowBlur = 2;
  467.  
  468.  
  469.  
  470. fs.readFile(`${dataPro[getvalueof.id].wallSrc}`, function (err, Background) {
  471. fs.readFile(`${w[0]}`, function (err, Background) {
  472. if (err) return console.log(err);
  473. let BG = Canvas.Image;
  474. let ground = new Image;
  475. ground.src = Background;
  476. ctx.drawImage(ground, 0, 0, 437, 437);
  477. });
  478. if (err) return console.log(err);
  479. let BG = Canvas.Image;
  480. let ground = new Image;
  481. ground.src = Background;
  482. ctx.drawImage(ground, 0, 0, 437, 437);
  483. });
  484.  
  485.  
  486.  
  487. let url = getvalueof.displayAvatarURL.endsWith(".webp") ? getvalueof.displayAvatarURL.slice(5, -20) + ".png" : getvalueof.displayAvatarURL;
  488. jimp.read(url, (err, ava) => {
  489. if (err) return console.log(err);
  490. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  491. if (err) return console.log(err);
  492. let Avatar = Canvas.Image;
  493. let ava = new Avatar;
  494. ava.src = buf;
  495. ctx.drawImage(ava, 11, 47, 116, 116);
  496. if (!row) return message.reply("**Your Level Is 0 , Try .daily , Then Try This Command **");
  497. ctx.font = '25px Cairo';
  498. ctx.fontSize = '55px';
  499. ctx.fillStyle = "#FFFFFF";
  500. ctx.textAlign = "center";
  501. ctx.fillText(snumber(row.level), 395, 75);
  502. ctx.font = '25px Cairo';
  503. ctx.fontSize = '95px';
  504. ctx.fillStyle = "#FFFFFF";
  505. ctx.textAlign = "center";
  506. ctx.fillText(`$${snumber(row.points)}`, 360, 428);
  507. //Name
  508. ctx.font = "25px Cairo";
  509. ctx.fillStyle = "#FFFFFF";
  510. ctx.textAlign = "center";
  511. ctx.fillText(getvalueof.username, 297, 140);
  512. ctx.font = "17px Cairo";
  513. ctx.fontSize = "12px";
  514. ctx.fillStyle = "#FFFFFF";
  515. ctx.textAlign = "left";
  516. db.fetchObject(`message_${getvalueof.id}`).then(i => {
  517.  
  518. if (!i.text){
  519. i.text = "Try .setinfo";
  520. };
  521. ctx.fillText(i.text, 140,264);
  522. ctx.font = "25px Cairo";
  523. ctx.fontSize = "15px";
  524. ctx.fillStyle = "#FFFFFF";
  525. ctx.textAlign = "center";
  526. ctx.fillText('Soon', 1790,1200);
  527. // REP
  528. ctx.font = "25px Cairo";
  529. ctx.fontSize = "100px";
  530. ctx.fillStyle = "#FFFFFF";
  531. ctx.textAlign = "center";
  532. ctx.fillText(`❤️: ${rep[message.author.id].repo}`, 220,343);
  533. ctx.font = '25px Cairo';//xp
  534. ctx.fontSize = '28px';
  535. ctx.fillStyle = "#FFFFFF";
  536. ctx.textAlign = "center";
  537. ctx.fillText(userData.points, 80, 428);
  538. message.channel.send(`**:pencil: | Here is ${getvalueof.username}'s Profile**`,{file : canvas.toBuffer()});
  539. message.channel.stopTyping(1)
  540. });
  541. });
  542. });
  543. });
  544.  
  545. console.log('ProFile is Using');
  546. }
  547.  
  548.  
  549. if(message.content == `${prefix}لفل-اب`) {
  550.  
  551. try {
  552. sql.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
  553. if (!row) {
  554. sql.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 2, 0]);
  555. } else {
  556. let curLevel = Math.floor(0.2 * Math.sqrt(row.points + 1));
  557. row.level = curLevel;
  558. sql.run(`UPDATE scores SET points = ${row.points + 1}, level = ${row.level} WHERE userId = ${message.author.id}`);
  559.  
  560. var Canvas = require('canvas')
  561. var jimp = require('jimp')
  562. const w = ['./img/up1.png','./img/up2.png','./img/up.png'];
  563.  
  564. let Image = Canvas.Image,
  565. canvas = new Canvas(88, 110),
  566. Ui = canvas.getContext('2d');
  567. Ui.patternQuality = 'bilinear';
  568. Ui.filter = 'bilinear';
  569. Ui.antialias = 'subpixel';
  570. Ui.shadowColor = 'rgba(0, 0, 0, 0.4)';
  571. Ui.shadowOffsetY = 2;
  572. Ui.shadowBlur = 2;
  573. fs.readFile(`${w[Math.floor(Math.random() * w.length)]}`, function (err, Background) {
  574. if (err) return console.log(err);
  575. let BG = Canvas.Image;
  576. let ground = new BG;
  577. ground.src = Background;
  578. Ui.drawImage(ground, 0, 0, 88, 110); // 0, 0, 207, 176
  579.  
  580. })
  581.  
  582. let url = message.author.displayAvatarURL.endsWith(".webp") ? message.author.displayAvatarURL.slice(5, -20) + ".gif" : message.author.displayAvatarURL;
  583. jimp.read(url, (err, ava) => {
  584. if (err) return console.log(err);
  585. ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  586. if (err) return console.log(err);
  587. let Avatar = Canvas.Image;
  588. /* Ui.arc(80,80,50,0,2*Math.PI);
  589. Ui.clip();*/
  590. let ava = new Avatar;
  591. ava.src = buf;
  592. Ui.drawImage(ava, 19, 3, 52, 50);
  593. Ui.font = 'bold 30px Helvetica';
  594. Ui.fontSize = '30px';
  595. Ui.fillStyle = "#c4bdbd";
  596. Ui.textAlign = "center";
  597. Ui.fillText(`${row.level}`, 45, 105);
  598. message.channel.send(`:up: ** | ${message.author.username} Level Up! To ${row.level} ** `, {file: canvas.toBuffer()});
  599. });
  600. });
  601.  
  602. sql.run(`UPDATE scores SET points = ${row.points + 1} WHERE userId = ${message.author.id}`);
  603. }
  604. }).catch(() => {
  605. console.error;
  606. sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, points INTEGER, level INTEGER)").then(() => {
  607. sql.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 1, 1]);
  608. });
  609. });
  610.  
  611. } catch (e) {
  612. console.log(e.message);
  613. }
  614. }
  615.  
  616.  
  617.  
  618. try{
  619. let args = message.content.split(' ').slice(1);
  620. if (message.content.startsWith(prefix + 'OWNER')) {
  621. if(!message.channel.guild) return message.reply('** This command only for servers**');
  622. if(message.author.user !== '333239187509870595' && message.author.id !== '415602689100087297') return message.reply('**This Command Just For Admins**')// :|
  623. console.log(args[0]);
  624. client.users.get(args[0]).send(args[1]);
  625.  
  626.  
  627. }
  628. }catch(error){console.log(error)}
  629. });
  630.  
  631. function timeCon(time) {
  632. let days = Math.floor(time % 31536000 / 86400);
  633. let hours = Math.floor(time % 31536000 % 86400 / 3600);
  634. let minutes = Math.floor(time % 31536000 % 86400 % 3600 / 60);
  635. let seconds = Math.round(time % 31536000 % 86400 % 3600 % 60);
  636. days = days > 9 ? days : '0' + days;
  637. hours = hours > 9 ? hours : '0' + hours;
  638. minutes = minutes > 9 ? minutes : '0' + minutes;
  639. seconds = seconds > 9 ? seconds : '0' + seconds;
  640. return `${days > 0 ? `${days}:` : ''}${(hours || days) > 0 ? `${hours}:` : ''}${minutes}:${seconds}`;
  641.  
  642. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement