daily pastebin goal
29%
SHARE
TWEET

Untitled

WoLF_UsA Mar 20th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {
  2.     get
  3. } = require('snekfetch');
  4.  
  5. let inv = JSON.parse(fs.readFileSync("./userD.json", "UTF8"))
  6.  
  7. const invs = JSON.parse(fs.readFileSync("./invites.json", "UTF8"))
  8.  
  9. const wait = require('util').promisify(setTimeout);
  10.  
  11. client.on('ready', () => {
  12.     wait(1000);
  13.  
  14.     client.guilds.forEach(g => {
  15.         if (g.members.get(client.user.id).hasPermission("MANAGE_GUILD"))
  16.             g.fetchInvites().then(guildInvites => {
  17.                 invs[g.id] = guildInvites;
  18.             });
  19.     });
  20. });
  21.  
  22. client.on('guildMemberAdd', member => {
  23.     member.guild.fetchInvites().then(guildInvites => {
  24.         const ei = invs[member.guild.id];
  25.         invs[member.guild.id] = guildInvites;
  26.         const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
  27.         const inviter = client.users.get(invite.inviter.id);
  28.         inv[member.user.id + member.guild.id].inviter = invite.inviter.id;
  29.         fs.writeFile("./invites.json", JSON.stringify(inv), function (err) {
  30.             if (err) throw err;
  31.         });
  32.     });
  33. });
  34.  
  35. client.on('message', async message => {
  36.     if (message.content.startsWith(prefix + "id")) {
  37.         let mem = message.mentions.members.first() || message.member;
  38.         let auth = message.mentions.users.first() || message.author;
  39.         const imageUrlRegex = /\?size=2048$/g;
  40.         const name = mem.displayName.length > 10 ? mem.displayName.substring(0, 11) + "..." : mem.displayName;
  41.  
  42.         const {
  43.             body: ava
  44.         } = await get(auth.displayAvatarURL.replace(imageUrlRegex, "?size=128"));
  45.  
  46.         const img = await readFile("./id_1.png");
  47.         const millis = new Date().getTime() - auth.createdAt.getTime();
  48.         const now = new Date();
  49.         const createdAt = millis / 1000 / 60 / 60 / 24;
  50.         const millisj = new Date().getTime() - mem.joinedAt.getTime();
  51.         const nowj = new Date();
  52.         const joinedAt = millisj / 1000 / 60 / 60 / 24;
  53.  
  54.         if (!inv[mem.id + message.guild.id]) inv[mem.id + message.guild.id] = {
  55.             inviter: "Not stored in database",
  56.             totalSecs: 0
  57.         }
  58.  
  59.         fs.writeFile("./userD.json", JSON.stringify(inv), function (err) {
  60.             if (err) throw err;
  61.         });
  62.         // Invites
  63.         const guildInvites = await message.guild.fetchInvites();
  64.         let invites = 0;
  65.         guildInvites.forEach(i => {
  66.             if (i.inviter.id === auth.id) {
  67.                 invites += i.uses;
  68.             }
  69.         }) // اصلا البوت معاه انفايتات؟؟؟؟
  70.  
  71.         let inviter = client.users.get(inv[mem.id + message.guild.id].inviter);
  72.  
  73.         const {
  74.             body: bot
  75.         } = await get(message.guild.iconURL.replace(imageUrlRegex, "?size=128"));
  76.         let cnvs = require("canvas-constructor");
  77.         let canvas = new cnvs.Canvas(417, 181)
  78.         canvas.addImage(img, 0, 0, 417, 181)
  79.         canvas.addRoundImage(bot, 7, 1, 29, 29, 25)
  80.         canvas.setShadowColor("rgba(22, 22, 22, 1)") // This is a nice colour for a shadow.
  81.         canvas.setShadowOffsetY(3) // Drop the shadow by 5 pixels.
  82.         canvas.setShadowBlur(03) // Blur the shadow by 10.
  83.         canvas.save()
  84.             .addRoundImage(ava, 320, 55, 78, 78, 39)
  85.             .setTextAlign("center")
  86.             .setTextFont("8pt Cairo")
  87.         canvas.setColor((mem.highestRole.hexColor === "#000000") ? "#ffffff" : mem.highestRole.hexColor)
  88.         canvas.addText(name, 360, 162)
  89.         canvas.setColor("#FFFFFF")
  90.         canvas.addText(createdAt.toFixed(), 192, 77)
  91.         canvas.addText((joinedAt.toFixed().length >= 3) ? joinedAt.toFixed() : joinedAt.toFixed() + " يوم", 257.5, 77)
  92.         canvas.addText("0", 195, 130)
  93.         canvas.addText("0", 258, 130)
  94.         canvas.addText(`${inv[mem.id+message.guild.id].totalSecs} ثانية`, 205, 163)
  95.         canvas.addText((invites === 1 || invites === 0) ? invites + " عضو" : invites + " أعضاء", 120, 128)
  96.         canvas.addText((inviter) ? inviter.username : "لم يتم تحديدة", 110, 77)
  97.         if (inviter) {
  98.             const {
  99.                 body: buffer
  100.             } = await get(inviter.avatarURL.replace(imageUrlRegex, "?size=128"))
  101.  
  102.             canvas.addRoundImage(buffer, 14, 59, 30, 30, 15)
  103.  
  104.         }
  105.  
  106.         //.addText("Joined at: ", 120, 100)
  107.         message.channel.send({
  108.             file: canvas.toBuffer()
  109.         })
  110.     }
  111. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top