SHARE
TWEET

welcome

khaliid404 Aug 20th, 2019 75 in 331 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('guildMemberAdd',async member => {
  2.             if(!welcome[member.guild.id]) welcome[member.guild.id] = {
  3.           onoff: 'Off'
  4.         }
  5.     if(welcome[member.guild.id].onoff === 'Off') return;
  6.     const Canvas = require('canvas');
  7.     const jimp = require('jimp');
  8.     const w = ['./join.png'];
  9.           let Image = Canvas.Image,
  10.               canvas = new Canvas(800, 300),
  11.               ctx = canvas.getContext('2d');
  12.           ctx.patternQuality = 'bilinear';
  13.           ctx.filter = 'bilinear';
  14.           ctx.antialias = 'subpixel';
  15.           ctx.shadowColor = 'rgba(0, 0, 0, 0.4)';
  16.           ctx.shadowOffsetY = 2;
  17.           ctx.shadowBlur = 2;
  18.           ctx.stroke();
  19.           ctx.beginPath();
  20.    
  21.           fs.readFile(`${w[Math.floor(Math.random() * w.length)]}`, function (err, Background) {
  22.               if (err) return console.log(err);
  23.               let BG = Canvas.Image;
  24.               let ground = new Image;
  25.               ground.src = Background;
  26.               ctx.drawImage(ground, 0, 0, 700, 300);
  27.    
  28.   })
  29.    
  30.                   let url = member.user.displayAvatarURL.endsWith(".webp") ? member.user.displayAvatarURL.slice(5, -20) + ".png" : member.user.displayAvatarURL;
  31.                   jimp.read(url, (err, ava) => {
  32.                       if (err) return console.log(err);
  33.                       ava.getBuffer(jimp.MIME_PNG, (err, buf) => {
  34.                    if (err) return console.log(err);
  35.    
  36.             ctx.font = '36px Arial';
  37.             ctx.fontSize = '72px';
  38.             ctx.fillStyle = "#ffffff";
  39.             ctx.textAlign = "center";
  40.             ctx.fillText(member.user.username, 545, 177);
  41.            
  42.             ctx.font = '16px Arial Bold';
  43.             ctx.fontSize = '72px';
  44.             ctx.fillStyle = "#ffffff";
  45.             ctx.textAlign = "center";
  46.             ctx.fillText(`Your The Member ${member.guild.memberCount}`, 580, 200);
  47.  
  48.             let Avatar = Canvas.Image;
  49.             let ava = new Avatar;
  50.             ava.src = buf;
  51.             ctx.beginPath();
  52.                  ctx.arc(122.8, 122.5, 85.3, 0, Math.PI*2, true);
  53.                    ctx.closePath();
  54.                      
  55.             ctx.clip();
  56.            // ctx.drawImage(ava, 36, 21, 260, 260);
  57.                   ctx.drawImage(ava, 249, 67, 260, 260);
  58.             let c = member.guild.channels.find('name', `welcome`)
  59.             if(!c) return;
  60.             c.sendFile(canvas.toBuffer());
  61.    
  62.   });
  63.   });
  64.   });
  65.  
  66.   const invites = {};
  67.  
  68. const wait = require('util').promisify(setTimeout);
  69.  
  70. client.on('ready', () => {
  71.   wait(1000);
  72.  
  73.   client.guilds.forEach(g => {
  74.     g.fetchInvites().then(guildInvites => {
  75.       invites[g.id] = guildInvites;
  76.     });
  77.   });
  78. });
  79.  
  80. client.on('guildMemberAdd', member => {
  81.                     if(!welcome[member.guild.id]) welcome[member.guild.id] = {
  82.                   by: 'Off'
  83.                 }
  84.     if(welcome[member.guild.id].by === 'Off') return;
  85.   member.guild.fetchInvites().then(guildInvites => {
  86.     const ei = invites[member.guild.id];
  87.     invites[member.guild.id] = guildInvites;
  88.     const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
  89.     const inviter = client.users.get(invite.inviter.id);
  90.     const logChannel = member.guild.channels.find(channel => channel.name === `${welcome[member.guild.id].channel}`);
  91.     if(!logChannel) return;
  92.       setTimeout(() => {
  93.     logChannel.send(` ** Middle East Community ™ |  https://www.mec-c.net/ |**
  94. **- Your Name** : ${member}
  95. **- Invited By** : <@${inviter.id}>`);
  96.   },2000)
  97.   });
  98. });
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top