Advertisement
Donovan_DMC

guildMemberAdd event

Jul 25th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on("guildMemberAdd", async (member) => {
  2.     var botCount=0;
  3.     var userCount=0;
  4.     client.guilds.find("id",config.guildID).members.forEach((member) => {
  5.         if(member.user.bot) botCount++;
  6.         if(!member.user.bot) userCount++;
  7.     });
  8.     client.guilds.find("id",config.guildID).channels.find("id",config.memberCountStatsChannel).edit({name:`Member Count: ${client.guilds.find("id",config.guildID).memberCount}`}, "stats");
  9.     client.guilds.find("id",config.guildID).channels.find("id",config.botCountStatsChannel).edit({name:`Bot Count: ${botCount}`}, "stats");
  10.     client.guilds.find("id",config.guildID).channels.find("id",config.userCountStatsChannel).edit({name:`User Count: ${userCount}`}, "stats");
  11.     if(member.user.bot) return;
  12.     changeNames();
  13.     var look=await client.guilds.find("id",config.guildID).channels.find("name",member.id);
  14.     if(!look) {
  15.         var ch = await client.guilds.find("id",config.guildID).createChannel(member.id,"text",[{allow:"379968",deny:"805449745",id:member.id},{allow:"0",deny:"1024",id:config.roles.everyone.id},{allow:"805829713",deny:0,id:client.user.id},{allow:"519248",deny:"805310465",id:config.roles.staff.id}],`Registration: ${member.user.tag}`);
  16.         ch.setParent(config.registrationCategory);
  17.    
  18.         var a = await ch.send(`<@!${member.id}>, Welcome to your registration channel! Please use the command **$register** to begin the registration process!\n\nIf the registration stops working, or times out, start over!`);
  19.         a.pin();
  20.         member.send(`Welcome to **${member.guild.name}**! Please go to the channel <#${ch.id}> to register!`);
  21.     } else {
  22.         look.overwritePermissions(member.id, {
  23.             CREATE_INSTANT_INVITE: false,
  24.             MANAGE_CHANNELS: false,
  25.             MANAGE_ROLES: false,
  26.             MANAGE_WEBHOOKS: false,
  27.             VIEW_CHANNEL: true,
  28.             SEND_MESSAGES: true,
  29.             SEND_TTS_MESSAGES: false,
  30.             MANAGE_MESSAGES: false,
  31.             EMBED_LINKS: true,
  32.             ATTACH_FILES: true,
  33.             READ_MESSAGE_HISTORY: true,
  34.             MENTION_EVERYONE: false,
  35.             USE_EXTERNAL_EMOJIS: true,
  36.             ADD_REACTIONS: true
  37.         }, `Registration: ${member.user.tag}`);
  38.         look.overwritePermissions(config.roles.everyone.id, {READ_MESSAGES: false}, `Registration: ${member.user.tag}`);
  39.         look.overwritePermissions(client.user.id, {
  40.             CREATE_INSTANT_INVITE: true,
  41.             MANAGE_CHANNELS: true,
  42.             MANAGE_ROLES: true,
  43.             MANAGE_WEBHOOKS: true,
  44.             VIEW_CHANNEL: true,
  45.             SEND_MESSAGES: true,
  46.             SEND_TTS_MESSAGES: true,
  47.             MANAGE_MESSAGES: true,
  48.             EMBED_LINKS: true,
  49.             ATTACH_FILES: true,
  50.             READ_MESSAGE_HISTORY: true,
  51.             MENTION_EVERYONE: true,
  52.             USE_EXTERNAL_EMOJIS: true,
  53.             ADD_REACTIONS: true
  54.         }, `Registration: ${member.user.tag}`);
  55.         look.overwritePermissions(config.roles.staff.id, {
  56.             CREATE_INSTANT_INVITE: false,
  57.             MANAGE_CHANNELS: true,
  58.             MANAGE_ROLES: false,
  59.             MANAGE_WEBHOOKS: false,
  60.             VIEW_CHANNEL: true,
  61.             SEND_MESSAGES: true,
  62.             SEND_TTS_MESSAGES: false,
  63.             MANAGE_MESSAGES: true,
  64.             EMBED_LINKS: true,
  65.             ATTACH_FILES: true,
  66.             READ_MESSAGE_HISTORY: true,
  67.             MENTION_EVERYONE: true,
  68.             USE_EXTERNAL_EMOJIS: true,
  69.             ADD_REACTIONS: true
  70.         }, `Registration: ${member.user.tag}`);
  71.        
  72.         var a = await look.send("Welcome to your registration channel! This is currently a work in progress, so please go to <#452586108556017704>!");
  73.         a.pin();
  74.         member.send(`Welcome to **${member.guild.name}**! Please go to the channel <#${look.id}> to register!`);
  75.     }
  76. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement