DudeThatsErin

index.js guild on

Mar 5th, 2021 (edited)
200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('guildCreate', guild => {
  2.  
  3.   console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
  4.  
  5.     try {
  6.     guild.members.cache.map( member => {
  7.       connection.query(
  8.            `INSERT INTO Points (guildId, user) VALUES ('${guild.id}', '${member.id}')`
  9.          );
  10.     });
  11.    }
  12.    catch{console.log(error);}
  13.    let challenge_role = guild.roles.cache.find(r => r.name === 'Participants');
  14.    let participants = guild.members.cache.filter(member => member.roles.cache.find(role => role == challenge_role)).map(mems => mems.user.id);
  15.    let challenge_channel = guild.channels.cache.find(c => c.name === 'Challenges');
  16.    if(!challenge_channel) {
  17.     guild.channels.create('Challenges', {
  18.         type: 'text',
  19.         reason: 'Sakura Moon needed a Challenges channel for the Challenges handler.',
  20.     }).then(console.log('The Challenges channel did not exist so I created one!')).catch(console.error);
  21. }
  22.    let submissions_channel = guild.channels.cache.find(ch => ch.name === 'Submissions');
  23.    if(!submissions_channel) {
  24.     guild.channels.create('Submissions', {
  25.         type: 'text',
  26.         reason: 'Sakura Moon needed a Submissions channel for the Challenges handler.'
  27.     }).then(console.log('The Submissions channel did not exist so I created one!')).catch(console.error);
  28. }
  29.  
  30.   connection.query(
  31.     `INSERT INTO Challenges (guildId, player, challengeAnnouncementsChannel, submissionsDumpChannel) VALUES ('${guild.id}', '${participants.id}', '${challenge_channel.id}', '${submissions_channel.id}')`
  32.   );
  33. });
RAW Paste Data