Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on('guildCreate', guild => {
- console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
- try {
- guild.members.cache.map( member => {
- connection.query(
- `INSERT INTO Points (guildId, user) VALUES ('${guild.id}', '${member.id}')`
- );
- });
- }
- catch{console.log(error);}
- let challenge_role = guild.roles.cache.find(r => r.name === 'Participants');
- let participants = guild.members.cache.filter(member => member.roles.cache.find(role => role == challenge_role)).map(mems => mems.user.id);
- let challenge_channel = guild.channels.cache.find(c => c.name === 'Challenges');
- if(!challenge_channel) {
- guild.channels.create('Challenges', {
- type: 'text',
- reason: 'Sakura Moon needed a Challenges channel for the Challenges handler.',
- }).then(console.log('The Challenges channel did not exist so I created one!')).catch(console.error);
- }
- let submissions_channel = guild.channels.cache.find(ch => ch.name === 'Submissions');
- if(!submissions_channel) {
- guild.channels.create('Submissions', {
- type: 'text',
- reason: 'Sakura Moon needed a Submissions channel for the Challenges handler.'
- }).then(console.log('The Submissions channel did not exist so I created one!')).catch(console.error);
- }
- connection.query(
- `INSERT INTO Challenges (guildId, player, challengeAnnouncementsChannel, submissionsDumpChannel) VALUES ('${guild.id}', '${participants.id}', '${challenge_channel.id}', '${submissions_channel.id}')`
- );
- });
Add Comment
Please, Sign In to add comment