-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwhitelist.js
474 lines (420 loc) · 19.3 KB
/
whitelist.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
require('dotenv').config();
const { Client, ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const fs = require("fs");
/**
*
* @param {Client} client
*/
module.exports = async (client) => {
// code
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand() && !interaction.isButton() && !interaction.isModalSubmit() && !interaction.showModal()) return;
if (interaction.isCommand()) {
if (interaction.commandName == "setup") {
let applyChannel = client.channels.cache.get(process.env.ApplyChannel)
if (!applyChannel) return;
let hasRole = interaction.member.roles.cache.has(process.env.InteractionRole);
if (hasRole) {
let btnrow = new ActionRowBuilder().addComponents([
new ButtonBuilder()
.setStyle(ButtonStyle.Primary)
.setCustomId("ap_apply")
.setLabel("Apply WhiteList")
.setEmoji("📑"),
]);
applyChannel.send({
embeds: [
new EmbedBuilder()
.setTitle(`DHRUVAM APPLICATIONS`)
.setAuthor({ name: `${process.env.ServerName} | Server Application`, iconURL: process.env.ServerLogo })
.setColor("#00e5ff")
.setThumbnail("https://ik.imagekit.io/yg4xrysan/RageGaming/Dhruvam/BOT/123444d_43EFIfH9Q-.webp")
.setImage('https://ik.imagekit.io/yg4xrysan/RageGaming/Dhruvam/BOT/DR3P1234j_TqGJUBxWjy.webp')
.setFooter({ text: "Test" ? `${process.env.ServerName}` : `${process.env.ServerName}` })
.setTimestamp(new Date())
],
components: [btnrow],
});
interaction.reply({
content: `> Setup in ${applyChannel}`,
});
} else {
interaction.reply({
content: `You don't have the privilage to do this command contact Admins for more information`,
ephemeral: true,
});
}
} else if (interaction.commandName == "acceptwl") {
await interaction.deferReply({ ephemeral: true });
let hasRole = interaction.member.roles.cache.has(process.env.InteractionRole);
if (hasRole) {
const user = interaction.options.getMember('user');
let acceptchannel = interaction.guild.channels.cache.get(
process.env.AcceptChannel
);
const acceptEmbed = new EmbedBuilder()
.setColor("#00d0ff")
.setAuthor({ name: 'DHRUVAM', iconURL: client.user.displayAvatarURL({ dynamic: true }) })
.setThumbnail(interaction.user.displayAvatarURL({ dynamic: true }))
.setImage('https://ik.imagekit.io/yg4xrysan/RageGaming/Dhruvam/BOT/34Untitled-1_MdzWv8Q4U.webp')
.addFields([
{
name: '\n\u200b\nServer Name ',
value: `\`\`\`DHRUVAM\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhitelist Status',
value: `\`\`\`✅ WHITELISTED\`\`\``,
inline: true
},
])
.setTimestamp()
.setFooter({ text: `${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL({ dynamic: true }) });
try {
await user.roles.add(process.env.WhiteListRole).catch(e => { console.log(e) })
await user.roles.remove(process.env.PendingRole).catch(e => { console.log(e) })
acceptchannel.send({ content: `<@${user.user.id}> 𝙔𝙊𝙐𝙍 𝙑𝙄𝙎𝘼 𝙃𝘼𝙎 𝘽𝙀𝙀𝙉 𝘼𝘾𝘾𝙀𝙋𝙏𝙀𝘿. 𝙀𝙉𝙅𝙊𝙔 𝘿𝙃𝙍𝙐𝙑𝘼𝙈 𝙍𝙊𝙇𝙀𝙋𝙇𝘼𝙔.`, embeds: [acceptEmbed] });
await user.send({ content: `<@${user.user.id}> 𝙔𝙊𝙐𝙍 𝙑𝙄𝙎𝘼 𝙃𝘼𝙎 𝘽𝙀𝙀𝙉 𝘼𝘾𝘾𝙀𝙋𝙏𝙀𝘿. 𝙀𝙉𝙅𝙊𝙔 𝘿𝙃𝙍𝙐𝙑𝘼𝙈 𝙍𝙊𝙇𝙀𝙋𝙇𝘼𝙔.`, embeds: [acceptEmbed] })
interaction.editReply({
content: `The message has been send on <#${process.env.AcceptChannel}>`,
ephemeral: true,
});
return;
} catch (error) {
if (error.code === 50007) {
interaction.editReply({
content: `The mentioned user has blocked their DMs. Don't worry, the role has been added.`,
ephemeral: true,
});
} else {
interaction.reply({
content: `An error occurred while processing your request.`,
ephemeral: true,
}).catch(e => {
interaction.editReply({ content: `An error occurred while processing your request.`, ephemeral: true });
});
}
return;
}
} else {
interaction.reply({
content: `You don't have the privilage to do this command contact <@813966990674493511> or other admins for more information`,
ephemeral: true,
});
}
}
//For Form Opening were handled by here and other button events
} else if (interaction.isButton()) {
if (interaction.customId == "ap_apply") {
let application_modal = new ModalBuilder()
.setTitle(`Whitelist Applications`)
.setCustomId(`application_modal`);
const user_name = new TextInputBuilder()
.setCustomId("ap_username")
.setLabel(`What is your name ?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(25)
.setRequired(true)
.setPlaceholder(`Enter you real name`)
.setStyle(TextInputStyle.Short);
const user_age = new TextInputBuilder()
.setCustomId("ap_userage")
.setLabel(`What is your real Age`.substring(0, 45))
.setMinLength(1)
.setMaxLength(2)
.setRequired(true)
.setPlaceholder(`Enter you Age`)
.setStyle(TextInputStyle.Short);
const user_ingameName = new TextInputBuilder()
.setCustomId("ap_useringameName")
.setLabel(`What is your in-game Name ?`.substring(0, 45))
.setMinLength(4)
.setMaxLength(30)
.setRequired(true)
.setPlaceholder(`Enter your in-game Name`)
.setStyle(TextInputStyle.Short);
const user_email = new TextInputBuilder()
.setCustomId("ap_useremail")
.setLabel(`What is your email-ID`.substring(0, 45))
.setMinLength(10)
.setMaxLength(50)
.setRequired(true)
.setPlaceholder(`Enter your email address`)
.setStyle(TextInputStyle.Short);
const user_exp = new TextInputBuilder()
.setCustomId("ap_userexp")
.setLabel(`What is your roleplay experince`.substring(0, 45))
.setMinLength(6)
.setMaxLength(1000)
.setRequired(true)
.setPlaceholder(`Enter your current roleplay experince`)
.setStyle(TextInputStyle.Paragraph);
let row_username = new ActionRowBuilder().addComponents(user_name);
let row_userage = new ActionRowBuilder().addComponents(user_age);
let row_useringameName = new ActionRowBuilder().addComponents(user_ingameName);
let row_useremail = new ActionRowBuilder().addComponents(user_email);
let row_userexp = new ActionRowBuilder().addComponents(user_exp);
application_modal.addComponents(row_username, row_userage, row_useringameName, row_useremail, row_userexp);
try {
await interaction.showModal(application_modal);
} catch (error) {
console.error('Error Showing Modals:', error);
}
} else if (interaction.customId == "ap_pending") {
let embed = new EmbedBuilder(
interaction.message.embeds[0]
).setColor("Yellow");
interaction.message.edit({
embeds: [embed],
components: [],
});
let ap_user = interaction.guild.members.cache.get(
embed.data.footer.text
);
let pendingchannel = interaction.guild.channels.cache.get(
process.env.PendingChannel
);
enqcode = embed.data.fields[0].value
sliced_enq = enqcode.slice(3, 7)
const pendingEmbed = new EmbedBuilder()
.setColor("Yellow")
.setAuthor({ name: 'DHRUVAM', iconURL: client.user.displayAvatarURL({ dynamic: true }) })
.setThumbnail(interaction.user.displayAvatarURL({ dynamic: true }))
.addFields([
{
name: '\n\u200b\nServer Name ',
value: `\`\`\`DHRUVAM\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhitelist Status',
value: `\`\`\`⌛ Pending\`\`\``,
inline: true
},
{
name: '\n\u200b\nEnquiry ID',
value: `\`\`\`${sliced_enq}\`\`\``,
inline: true
},
])
.setImage('https://ik.imagekit.io/yg4xrysan/RageGaming/Dhruvam/BOT/U4ntitled-1_Il7c7B_QV.webp')
.setTimestamp()
.setFooter({ text: `${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL({ dynamic: true }) });
try {
await ap_user.roles.add(process.env.PendingRole).catch(e => { })
pendingchannel.send({ content: `<@${ap_user.user.id}> 𝙔𝙊𝙐𝙍 𝙑𝙄𝙎𝘼 𝘼𝙋𝙋𝙇𝙄𝘾𝘼𝙏𝙄𝙊𝙉 𝙃𝘼𝙎 𝘽𝙀𝙀𝙉 𝘼𝘾𝘾𝙀𝙋𝙏𝙀𝘿. 𝙑𝙄𝙎𝙄𝙏 <#1000400547897163796> 𝙏𝙊 𝘾𝙊𝙈𝙋𝙇𝙀𝙏𝙀 𝙏𝙃𝙀 𝙋𝙍𝙊𝘾𝙀𝘿𝙐𝙍𝙀.`, embeds: [pendingEmbed] });
ap_user.send({ content: `<@${ap_user.user.id}> 𝙔𝙊𝙐𝙍 𝙑𝙄𝙎𝘼 𝘼𝙋𝙋𝙇𝙄𝘾𝘼𝙏𝙄𝙊𝙉 𝙃𝘼𝙎 𝘽𝙀𝙀𝙉 𝘼𝘾𝘾𝙀𝙋𝙏𝙀𝘿. 𝙑𝙄𝙎𝙄𝙏 <#1000400547897163796> 𝙏𝙊 𝘾𝙊𝙈𝙋𝙇𝙀𝙏𝙀 𝙏𝙃𝙀 𝙋𝙍𝙊𝘾𝙀𝘿𝙐𝙍𝙀.`, embeds: [pendingEmbed] });
} catch (error) {
if (error.code === 50007) {
interaction.reply({
content: `The mentioned user has blocked their DMs. Don't worry, the role has been added.`,
ephemeral: true,
});
} else {
interaction.reply({
content: `An error occurred while processing your request.`,
ephemeral: true,
});
}
return;
}
} else if (interaction.customId == "ap_reject") {
let reject_reason_modal = new ModalBuilder()
.setTitle(`Whitelist Applications reject`)
.setCustomId(`reject_reason_modal`);
const reject_reason = new TextInputBuilder()
.setCustomId("ap_reject_reason")
.setLabel(`What is the reason for rejection ?`.substring(0, 45))
.setMinLength(5)
.setMaxLength(50)
.setRequired(true)
.setPlaceholder(`Enter rejection details`)
.setStyle(TextInputStyle.Short);
let row_reject_reason = new ActionRowBuilder().addComponents(reject_reason);
reject_reason_modal.addComponents(row_reject_reason);
try {
await interaction.showModal(reject_reason_modal);
} catch (error) {
console.error('Error showing Reject Modal:', error);
// If you catch an error here, it might indicate that the user has blocked DMs
}
}
//For Data Submition to the dedicated channel
} else if (interaction.isModalSubmit()) {
if (interaction.customId === 'application_modal') {
let user_name = interaction.fields.getTextInputValue("ap_username");
let user_age = interaction.fields.getTextInputValue("ap_userage");
let user_ingameName = interaction.fields.getTextInputValue("ap_useringameName");
let user_email = interaction.fields.getTextInputValue("ap_useremail");
let user_exp = interaction.fields.getTextInputValue("ap_userexp");
let finishChannel = interaction.guild.channels.cache.get(
process.env.LogChannel
);
if (!finishChannel) return;
let btnrow = new ActionRowBuilder().addComponents([
new ButtonBuilder()
.setStyle(ButtonStyle.Success)
.setCustomId("ap_pending")
.setLabel("Pending")
.setEmoji("⌛"),
new ButtonBuilder()
.setStyle(ButtonStyle.Danger)
.setCustomId("ap_reject")
.setLabel("Reject")
.setEmoji("✖️"),
]);
const fileName = 'Database.json';
var rowdata = fs.readFileSync(fileName, 'utf8'); // This will block the event loop, not recommended for non-cli programs.
var data = JSON.parse(rowdata);
var valueofwlid = data.id
finishChannel.send({
content: `Whitelist Application From <@${interaction.user.id}> \n<@&1048119915707650118> <@&1130791882558025728> <@&981442795229306912>`,
embeds: [
new EmbedBuilder()
.setAuthor({ name: `${process.env.ServerName} | Server Application Log`, iconURL: process.env.ServerLogo })
.setColor("Blue")
.setThumbnail(process.env.ServerLogo)
.setFooter({ text: "Test" ? `${process.env.ServerName}` : `${process.env.ServerName}` })
.setTimestamp(new Date())
.setTitle(`DHRUVAM APPLICATIONS LOGS`)
.addFields([
{
name: '\n\u200b\nEnquiry ID',
value: `\`\`\`${valueofwlid}\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhat is your name?',
value: `\`\`\`${user_name}\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhat is your age?',
value: `\`\`\`${user_age}\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhat is your in-game Name ?',
value: `\`\`\`${user_ingameName}\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhat is your email-ID',
value: `\`\`\`${user_email}\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhat is your roleplay experince',
value: `\`\`\`${user_exp}\`\`\``,
inline: false
},
])
.setFooter({
text: `${interaction.user.id}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
}),
],
components: [btnrow],
});
interaction.reply({
content: `Thank you for your application with code **#${valueofwlid}** ! We'll review it and be in touch.`,
ephemeral: true,
});
let updateingvalue = {
id: valueofwlid + 1
}
let encryptdata = JSON.stringify(updateingvalue);
fs.writeFileSync(fileName, encryptdata);
interaction.user.send({
content: `Thank you for your whitelist application. We'll review it and be in touch.`,
embeds: [
new EmbedBuilder()
.setAuthor({ name: `${process.env.ServerName} | Server Application`, iconURL: process.env.ServerLogo })
.setColor("Blue")
.setThumbnail(process.env.ServerLogo)
.setFooter({ text: "Test" ? `${process.env.ServerName}` : `${process.env.ServerName}` })
.setTimestamp(new Date())
.setTitle(`DHRUVAM APPLICATIONS`)
.addFields([
{
name: '\n\u200b\nMessage',
value: `\`\`\`Thank you for applying! \nWe will respond shortly.\`\`\``,
inline: true
},
{
name: '\n\u200b\nEnquiry ID?',
value: `\`\`\`${valueofwlid}\`\`\``,
inline: false
},
])
.setFooter({
text: `${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
}),
],
}).catch(e => { })
} else if (interaction.customId === 'reject_reason_modal') {
let reject_reasoninput = interaction.fields.getTextInputValue("ap_reject_reason");
let embed = new EmbedBuilder(
interaction.message.embeds[0]
).setColor("Red");
interaction.message.edit({
embeds: [embed],
components: [],
});
let ap_user = interaction.guild.members.cache.get(
embed.data.footer.text
);
try {
ap_user.send(`Your DHRUVAM whitelist application has been rejected by ${interaction.user.tag}`)
} catch (error) {
if (error.code === 50007) {
interaction.reply({
content: `The mentioned user has blocked their DMs. Don't worry, the role has been added.`,
ephemeral: true,
});
} else {
interaction.reply({
content: `An error occurred while processing your request.`,
ephemeral: true,
});
}
}
let rejectchannel = interaction.guild.channels.cache.get(
process.env.RejectChannel
);
const rejectEmbed = new EmbedBuilder()
.setColor("Red")
.setAuthor({ name: 'DHRUVAM', iconURL: client.user.displayAvatarURL({ dynamic: true }) })
.setThumbnail(`${ap_user.user.avatarURL()}`)
.addFields([
{
name: '\n\u200b\nServer Name ',
value: `\`\`\`DHRUVAM\`\`\``,
inline: false
},
{
name: '\n\u200b\nWhitelist Status',
value: `\`\`\`❌ Rejected\`\`\``,
inline: true
},
{
name: '\n\u200b\nReason',
value: `\`\`\`${reject_reasoninput}\`\`\``,
inline: true
},
])
.setImage('https://ik.imagekit.io/yg4xrysan/RageGaming/Dhruvam/BOT/visa-declined.webp')
.setTimestamp()
.setFooter({ text: `${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL({ dynamic: true }) });
rejectchannel.send({ content: `<@${ap_user.user.id}> 𝗬𝗢𝗨𝗥 𝗪𝗛𝗜𝗧𝗘𝗟𝗜𝗦𝗧 𝗪𝗔𝗦 𝗥𝗘𝗝𝗘𝗖𝗧𝗘𝗗..`, embeds: [rejectEmbed] });
ap_user.send({ content: `<@${ap_user.user.id}> 𝗬𝗢𝗨𝗥 𝗪𝗛𝗜𝗧𝗘𝗟𝗜𝗦𝗧 𝗪𝗔𝗦 𝗥𝗘𝗝𝗘𝗖𝗧𝗘𝗗..`, embeds: [rejectEmbed] });
interaction.reply({
content: `Reject Message has been sended to rejected channel`,
ephemeral: true,
});
}
}
})
};