-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
255 lines (227 loc) Β· 14.7 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
const Discord = require('discord.js')
const bot = new Discord.Client()
const auth = require("./auth")
const token = auth.token
const PREFIX = '!'
const helpeEmbed = new Discord.MessageEmbed()
.setColor('#d67922')
.setTitle('Application Assistance')
.setDescription('Find what you need!')
.setThumbnail('https://cdn.discordapp.com/attachments/322832417578811402/738419667986808942/mglogonew.png')
.addFields(
{ name: '!info', value: 'More informations about Money Guild recruitment.'},
{ name: '!apply', value: 'Begin a new application.' },
{ name: '!cancel', value: 'Cancel your current application'}, //, inline: true
{ name: '!confirm', value: 'Confirm your application. Warning! It will be instantly posted to our private recruitment channel'},
)
bot.on('ready', () => {
console.log('Bot is online!')
bot.channels.cache.get('737744651498291308').send(`Hello, I'm Miya, Money Guild application assistance.
Send me a **private message** to know more about our recruitment (**!info**), and to start your application! (**!apply**)
*If you're not looking to apply then ignore this message.*`);
})
//737744651498291308 FUYU
//737024926057365504 MG
bot.on('guildMemberAdd', member => {
member.send(`Welcome to the Money Guild server ${member.user.username} !
I'm Miya, your application assistance.
You'll find our rules here <#568971527127826432>. Please make sure you've read them thoroughly and agree with everything.
Type **!info** to better understand our recruitment process. Once you've read everything proceed to the next step.
Type !**apply** to begin your application.
*If you're not looking to apply then ignore this message.*`);
});
//<:MG:425692213733752849> EMOTE MG
let currentApplication = {}
bot.on('message', message => {
/* const guild = bot.guilds.get("737744651498291303");
let role = guild.roles.find(r => r.name === "Recruiter"); //message.
console.log(role)
let recruiters = message.guild.roles.get(role.id).members.map(m=>m.user.tag);
console.log(recruiters)
const filter = (reaction) => reaction.emoji.name === 'π' //&& user.id === message.author.id */
if (message.channel.type === 'dm') {
if (message.content.charAt(0) !== "!" && !message.author.bot) {
// APPLICATIONS --------------
if(message.content && currentApplication[message.author.id] && currentApplication[message.author.id].applying) {
if (currentApplication[message.author.id].timer && currentApplication[message.author.id].questionDepth === 7) {
// message.channel.awaitMessages().then(console.log('YAY'))
if (message.attachments.size > 0) {
currentApplication[message.author.id].motivation = message.content
currentApplication[message.author.id].image = message.attachments.first().url
currentApplication[message.author.id].questionDepth += 1
currentApplication[message.author.id].application = { embed: {
color: 3447003,
// author: {
// name: bot.user.username,
// },
title: `${message.author.username} Application`,
// url: "http://google.com",
// description: "This is a test embed to showcase what they look like and what they can do.",
fields: [{
name: "IGN",
value: `${currentApplication[message.author.id].name}`
},
{
name: "Average Playtime",
value: `${currentApplication[message.author.id].playtime}`
},
{
name: "Timer",
value: `${currentApplication[message.author.id].timer}`
},
{
name: "ZvZ Build",
value: `${currentApplication[message.author.id].build}`
},
{
name: "Previous Guilds",
value: `${currentApplication[message.author.id].guilds}`
},
{
name: "Expectation of Money Guild",
value: `${currentApplication[message.author.id].expectation}`
},
{
name: "English Rating",
value: `${currentApplication[message.author.id].english}`
},
{
name: "Motivation",
value: `${currentApplication[message.author.id].motivation}`
},
],
timestamp: new Date(),
image: {
url: currentApplication[message.author.id].image,
},
}
}
if(!message.author.bot) {
message.channel.send(currentApplication[message.author.id].application);
message.author.send(`Type **!confirm** to post your application. You can cancel it by typing **!cancel**`)
}
} else {
message.author.send(`Sorry, you didn't send *your motivation with a screenshot*!
Explain your reasons for wanting to join Money Guild **and** please upload a screenshot of your login page (**in the same message**) (no external links)`)
}
}
if (currentApplication[message.author.id].expectation && currentApplication[message.author.id].questionDepth === 6) {
currentApplication[message.author.id].english = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`Explain your reasons for wanting to join Money Guild and please upload a screenshot of your login page(no external links)`)
}
if (currentApplication[message.author.id].guilds && currentApplication[message.author.id].questionDepth === 5) {
currentApplication[message.author.id].expectation = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`Rate your English (Written & Oral) from 1 to 10`)
}
if (currentApplication[message.author.id].build && currentApplication[message.author.id].questionDepth === 4) {
currentApplication[message.author.id].guilds = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`What are you expecting from us ?`)
}
if (currentApplication[message.author.id].timer && currentApplication[message.author.id].questionDepth === 3) {
currentApplication[message.author.id].build = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`What's your previous guilds ?`)
}
if (currentApplication[message.author.id].playtime && currentApplication[message.author.id].questionDepth === 2) {
currentApplication[message.author.id].timer = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`What's your current ZVZ build/spec ?`)
}
if (currentApplication[message.author.id].name && currentApplication[message.author.id].questionDepth === 1) {
currentApplication[message.author.id].playtime = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`When do you normally play? (UTC)`)
}
if (currentApplication[message.author.id].questionDepth === 0) {
currentApplication[message.author.id].name = message.content
currentApplication[message.author.id].questionDepth += 1
if(!message.author.bot) message.author.send(`What's your daily average playtime ?`)
}
}
}
// COMMANDS --------------
let args = message.content.substring(PREFIX.length).split(" ")
switch(args[0]) {
case 'apply':
currentApplication[message.author.id] = {applying : true, questionDepth: 0}
// message.channel.send(exampleEmbed);
// console.log(message.author)
bot.channels.cache.get('737744651498291308').send(`<@${message.author.id}> begins a new application.`) // 737744651498291308
if(!message.author.bot) {
message.author.send(`Let's go ! You can type **!cancel** to cancel your application.
What's your name in game ?`)
}
break;
case 'confirm':
// 737744651498291308 Fuyu
// 737063941791809636 MG
if (currentApplication[message.author.id].application) {
if(!message.author.bot) message.author.send(`**Your application is posted.** Thank you !`)
// console.log(message.author)
bot.channels.cache.get('737744651498291308').send(`<@${message.author.id}> application done.`)
// console.log(message.mentions)
bot.channels.cache.get('737744651498291308').send(currentApplication[message.author.id].application).then(async msg => {
await msg.react('π');
await msg.react('π');
setTimeout( () => {
msg.awaitReactions(r => ['π', 'π'].includes(r.emoji.name), {max: 1})
.then(collected => {
// console.log(`Collected ${collected} reactions`)
// console.log(`Collected ${collected.size} reactions`)
const reaction = collected.first()
// console.log('reaction ----------------------', reaction, reaction.users.cache)
// console.log(Array.from(reaction.users.cache), '++')
if (reaction.emoji.name === 'π') {
message.author.send(`Your application is accepted. You need to pass our interview to be recruited. Tag our recruiters in xxxxx channel`)
// member.addRole(member.guild.roles.find("name", "Authorize"))
// .then(() => { console.log(`Added ${member.user.username} (${member.id}).`); })
// .catch(console.error);
let guild = reaction.message.channel.guild
let role = guild.roles.cache.find(r => r.name === "Recruiter");
let member = guild.members.cache.get(message.author.id)
console.log(member)
member.roles.add(role)
} else if (reaction.emoji.name === 'π') {
let recruiterInteract = Array.from(reaction.users.cache).find( recruiter => !recruiter[1].bot) //You can contact <@${recruiterInteract.id}>
message.author.send(`Your application was denied. Thank you for your interest in Money Guild! You can contact <@${recruiterInteract[1].id}> for more informations.`)
}
})
.catch(console.error);
}, 3000);
})
// CHOOSE CHANNEL + NO TAG
} else {
if(!message.author.bot) message.author.send(`You can't confirm your application. It's not full!`)
}
break;
case 'cancel':
currentApplication[message.author.id] = undefined
message.author.send(`Application canceled. Reapply with **!apply** whenever you want!`)
break;
case 'help':
// currentApplication[message.author.id] = undefined
if(!message.author.bot) message.author.send(helpeEmbed)
break;
case 'info':
if(!message.author.bot) message.author.send(`The recruitment process is dividing into three phases:
1. **Post your application**. With my assistance we'll build your application appropriately and make sure that you don't forget anything. (**!apply**)
2. If we believe that you're a good candidate to join the guild then you will be granted **the 'Interview Accepted' role** on Discord which will grant permissions to a new channel. Communicate there with our recruiters to proceed to the next step which will be the vocal interview.
3. And the final step will be hopefully **passing the interview**. This is to make sure that everybody knows about the rules, to have a discussion about the rules and guild in general while also making sure that you're going to be a good fit personality wise. The better your English the higher your chances of being accepted.
When the interview is done you'll either be invited to the guild or sent back into the wilderness to find a new home.
`)
break;
}
let commands = ['apply', 'cancel', 'confirm', 'help', 'info']
if (!commands.includes(args[0]) && message.content.charAt(0) === '!') {
if(!message.author.bot) message.author.send(`Sorry, I don't know this command. Type **!help** to see my command list!`)
}
}
})
// bot.on('messageReactionAdd', async (reaction, user) => {
// console.log("Message Reaction Add Top");
// console.log(reaction)
// })
bot.login(token)