This repository was archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication_manager.js
More file actions
291 lines (259 loc) · 13.1 KB
/
Copy pathapplication_manager.js
File metadata and controls
291 lines (259 loc) · 13.1 KB
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
const {
Client,
MessageActionRow,
MessageButton,
MessageEmbed,
Modal,
TextInputComponent,
} = require("discord.js");
const settings = require("./config");
/**
*
* @param {Client} client
* @param {settings} settings
*/
module.exports = async (client, settings) => {
// code
client.on("interactionCreate", async (interaction) => {
if (interaction.isCommand()) {
switch (interaction.commandName) {
case "setup":
{
let applyChannel = interaction.guild.channels.cache.get(
settings.applyChannel
);
if (!applyChannel) return;
let btnrow = new MessageActionRow().addComponents([
/* new MessageButton()
.setStyle("PRIMARY")
.setCustomId("ap_ping")
.setLabel("Ping me !!")
setEmoji("📶"),*/
new MessageButton()
.setStyle("SUCCESS")
.setCustomId("ap_apply")
.setLabel("Apply")
.setEmoji("📑"),
]);
applyChannel.send({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`__Developer Applications__`)
// .setDescription(
// `> If you would like to apply for developer, continue reading!`)
.addFields(
{ name: 'Requirements', value: 'You must have all the requirements below, or else your application will be denied.' },
{ name: '1. Ages 13-22', value: 'We only allow high school & college students to be a part of our team! ', inline: true },
{ name: '2. Web Development Experience', value: 'You must have at least 3 months of experience in popular website languages. ', inline: true },
{ name: '3. Able to commit 1-2 hours a week', value: 'You must be able to help out with development at least 1-3 hours a week, although, these are flexible times.', inline: true },
{
name: '4. Have these skills:', value: '__Must Know:__\n> Familiar with NodeJs\n> Familiar with HTML\n> Familiar with CSS\n> Familiar with NextJs\n__Bonuses:__\n> Knows MongoDB\n> Has worked with Discord API', inline: false
},
{
name: '\u200B', value: '> If you meet all these requirements, you may click the button below and start your application!'
},
)
.setFooter({ text: 'Expect to receive a response within 3-6 days', iconURL: 'https://techoptimum.org/img/logo.png' })
,
],
components: [btnrow],
});
interaction.reply({
content: `> Setup in ${applyChannel}`,
});
}
break;
case "ping":
{
interaction.reply({
content: `Bot's ping: ${client.ws.ping}`,
ephemeral: true,
});
}
break;
case "picture":
{
interaction.reply({
content: `picture xd`,
ephemeral: true,
})
}
default:
interaction.reply({
content: `Command not found: **${interaction.commandName}**`,
ephemeral: true,
});
break;
}
}
// for buttons
if (interaction.isButton()) {
switch (interaction.customId) {
case "ap_ping":
{
interaction.reply({
content: `i am working , now you can apply`,
ephemeral: true,
});
}
break;
case "ap_apply":
{
let application_modal = new Modal()
.setTitle(`Application System`)
.setCustomId(`application_modal`);
const user_name = new TextInputComponent()
.setCustomId("ap_username")
.setLabel(`What is your real name?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(50)
.setRequired(true)
.setPlaceholder(`Please type your first and last name`)
.setStyle("SHORT");
const user_why = new TextInputComponent()
.setCustomId("ap_userwhy")
.setLabel(`Why you are applying for staff?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(100)
.setRequired(true)
.setPlaceholder(`Share with us why you would like to join our team`)
.setStyle("PARAGRAPH");
const user_experience = new TextInputComponent()
.setCustomId("ap_user_experience")
.setLabel(`What previous experience do you carry?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(100)
.setRequired(true)
.setPlaceholder(`Share your work experience/volunteer experience`)
.setStyle("PARAGRAPH");
const prg_skills = new TextInputComponent()
.setCustomId("ap_prg_skills")
.setLabel(`What programming languages do you know?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(100)
.setRequired(true)
.setPlaceholder(`Share your programming skills/languages with us`)
.setStyle("PARAGRAPH");
const time_zone = new TextInputComponent()
.setCustomId("ap_time_zone")
.setLabel(`What timezone are you in?`.substring(0, 45))
.setMinLength(2)
.setMaxLength(30)
.setRequired(true)
.setPlaceholder(`Share your timezone with us`)
.setStyle("PARAGRAPH");
let row_username = new MessageActionRow().addComponents(user_name);
let row_userwhy = new MessageActionRow().addComponents(user_why);
let row_userexperience = new MessageActionRow().addComponents(user_experience);
let row_prg_skills = new MessageActionRow().addComponents(prg_skills);
let row_timezone = new MessageActionRow().addComponents(time_zone);
application_modal.addComponents(row_username, row_userwhy, row_userexperience, row_prg_skills, row_timezone);
await interaction.showModal(application_modal);
}
break;
case "ap_accept":
{
let embed = new MessageEmbed(
interaction.message.embeds[0]
).setColor("GREEN");
interaction.message.edit({
embeds: [embed],
components: [],
});
let ap_user = interaction.guild.members.cache.get(
embed.footer.text
);
ap_user.send(`**Congratulations ** 🎉\n The application you submitted to become a Developer was accepted!\n Please join our Staff server: https://discord.gg/cVGv2Ttx5F\n The executive management team will soon give you your roles upon joining. `).catch(e => { })
await interaction.member.roles.add(settings.helperrole).catch(e => { })
await interaction.member.roles.remove(settings.waitingrole).catch(e => { })
}
break;
case "ap_reject":
{
let embed = new MessageEmbed(
interaction.message.embeds[0]
).setColor("RED");
interaction.message.edit({
embeds: [embed],
components: [],
});
let ap_user = interaction.guild.members.cache.get(
embed.footer.text
);
ap_user.send(`We're sorry to say this... But, your application for Developer was denied.`).catch(e => { })
await interaction.member.roles.remove(settings.waitingrole).catch(e => { })
}
break;
default:
break;
}
}
// for modals
if (interaction.isModalSubmit()) {
let user_name = interaction.fields.getTextInputValue("ap_username");
let user_why = interaction.fields.getTextInputValue("ap_userwhy");
let user_experience = interaction.fields.getTextInputValue("ap_user_experience");
let time_zone = interaction.fields.getTextInputValue("ap_time_zone");
let prg_skills = interaction.fields.getTextInputValue("ap_prg_skills");
let finishChannel = interaction.guild.channels.cache.get(
settings.finishChannel
);
if (!finishChannel) return;
let btnrow = new MessageActionRow().addComponents([
new MessageButton()
.setStyle("SECONDARY")
.setCustomId("ap_accept")
.setLabel("Accept")
.setEmoji("✅"),
new MessageButton()
.setStyle("SECONDARY")
.setCustomId("ap_reject")
.setLabel("Reject")
.setEmoji("❌"),
]);
finishChannel.send({
embeds: [
new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`Application From ${interaction.user.tag}`)
.setDescription(
`${interaction.user} <t:${Math.floor(Date.now() / 1000)}:R>`
)
.addFields([
{
name: `Name:`,
value: `> ${user_name}`,
},
{
name: `They want to become a dev because:`,
value: `> ${user_why}`,
},
{
name: `Previous experience:`,
value: `> ${user_experience}`,
},
{
name: `Programming skills:`,
value: `> ${prg_skills}`,
},
{
name: `Timezone?`,
value: `> ${time_zone}`,
},
])
.setFooter({
text: `${interaction.user.id}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
}),
],
components: [btnrow],
});
interaction.reply({
content: `Good job! You're application has been submitted for review. Please give us a few days/weeks to review your application.`,
ephemeral: true,
});
await interaction.member.roles.add(settings.waitingrole).catch(e => { })
}
});
};