-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
177 lines (145 loc) · 7.25 KB
/
index.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
require("colors");
require('dotenv/config')
const { kMaxLength } = require("buffer");
const Discord = require("discord.js");
const db = require("pro.db");
const client = new Discord.Client({
shards: 'auto',
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.DirectMessageReactions,
Discord.GatewayIntentBits.DirectMessageTyping,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.GuildMessageTyping,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildPresences,
Discord.GatewayIntentBits.GuildScheduledEvents,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildWebhooks,
]
});
client.on("ready", async () => {
console.log(`[INFO]:`.cyan, `logged Us ${client.user.tag}`.green);
if (!db.has('panelMessage')) {
let embed = new Discord.EmbedBuilder()
.setTitle('Whitelist Bot')
.setColor('Blue')
.setDescription('Please click on button bollow and answer the quetions !')
.setImage(process.env.IMAGE_WHITELIST)
.setTimestamp()
.setFooter({ text: 'smith69.dev copyrigth 2024', iconURL: client.user.avatarURL() });
let button = new Discord.ButtonBuilder()
.setCustomId('buttonQ')
.setLabel('Get Whitelist')
.setEmoji('📑')
.setStyle(Discord.ButtonStyle.Primary);
let composent = new Discord.ActionRowBuilder()
.addComponents(button)
let msg = await client.channels.cache.get(process.env.APPLY_CHANNEL_ID).send({ embeds: [embed], components: [composent] });
db.set('panelMessage', msg.id)
}
});
client.on(Discord.Events.InteractionCreate, async interaction => {
if (interaction.isButton()) {
if (interaction.customId == 'buttonQ') {
const modal = new Discord.ModalBuilder()
.setCustomId('Qmodel')
.setTitle('Whitelist Bot Questions');
const q0 = new Discord.TextInputBuilder()
.setRequired(true)
.setCustomId('q0')
.setLabel("Real Name")
.setStyle(Discord.TextInputStyle.Short);
const q1 = new Discord.TextInputBuilder()
.setRequired(true)
.setCustomId('q1')
.setLabel("Full Name RP")
.setStyle(Discord.TextInputStyle.Short);
const q2 = new Discord.TextInputBuilder()
.setRequired(true)
.setCustomId('q2')
.setLabel("Real Age")
.setStyle(Discord.TextInputStyle.Short);
const q3 = new Discord.TextInputBuilder()
.setRequired(true)
.setCustomId('q3')
.setLabel("Steam Link")
.setStyle(Discord.TextInputStyle.Short);
const q4 = new Discord.TextInputBuilder()
.setRequired(true)
.setCustomId('q4')
.setLabel("Your RolePlaying Story")
.setStyle(Discord.TextInputStyle.Paragraph);
const q1A = new Discord.ActionRowBuilder().addComponents(q0);
const q2A = new Discord.ActionRowBuilder().addComponents(q1);
const q3A = new Discord.ActionRowBuilder().addComponents(q2);
const q4A = new Discord.ActionRowBuilder().addComponents(q3);
const q5A = new Discord.ActionRowBuilder().addComponents(q4);
modal.addComponents(q1A, q2A, q3A, q4A, q5A);
await interaction.showModal(modal);
} else if (interaction.customId == 'accept' || interaction.customId == 'reject') {
let req = interaction.customId == 'accept' ? true : false;
let member = interaction.guild.members.cache.get(db.get(`msg_${interaction.message.id}`));
try {
let list = db.get('pending_list')
db.set('pending_list', list.filter(u => u != member.id));
let role = interaction.guild.roles.cache.find(role => role.id == `${req ? process.env.ACCEPTED_ROLE_ID : process.env.REJECTED_ROLE_ID}`);
await member.roles.add(role);
await interaction.message.edit({ content: `**${interaction.customId.toString().toLocaleUpperCase()}ED BY ${interaction.user}**`, components: [] });
await client.channels.cache.get(process.env.ANNOUNCEMENT_CHANNEL_ID).send({content: req ? `${interaction.user} , You have Successfully Accepted !` : `${interaction.user} , You have been Rejected Please try again !`})
} catch (err) {
console.log(err)
}
}
}
if (interaction.isModalSubmit()) {
let list = db.get('pending_list') || []
if (list.includes(interaction.user.id)) return interaction.reply({content: `you have already a pending request , please wait !` , ephemeral: true})
let q0 = interaction.fields.getTextInputValue('q0');
let q1 = interaction.fields.getTextInputValue('q1');
let q2 = interaction.fields.getTextInputValue('q2');
let q3 = interaction.fields.getTextInputValue('q3');
let q4 = interaction.fields.getTextInputValue('q4');
let channel = client.channels.cache.get(process.env.STAFF_CHANNEL_ID);
let embed = new Discord.EmbedBuilder()
.setColor('Blue')
.setTitle('Whitelist Request')
.setDescription(`Whitelist request from: ${interaction.user}`)
.setThumbnail(interaction.user.avatarURL())
.addFields(
{ name: 'Real Name', value: q0, inline: false },
{ name: 'Full Name RP', value: q1, inline: false },
{ name: 'Real Age', value: q2, inline: false },
{ name: 'Steam Link', value: q3, inline: false },
{ name: 'Roleplay Story', value: q4, inline: false },
);
let accbutton = new Discord.ButtonBuilder()
.setCustomId('accept')
.setLabel('Accept')
.setStyle(Discord.ButtonStyle.Success);
let rejbutton = new Discord.ButtonBuilder()
.setCustomId('reject')
.setLabel('Reject')
.setStyle(Discord.ButtonStyle.Danger);
let composent = new Discord.ActionRowBuilder()
.addComponents(accbutton, rejbutton)
let msg = await channel.send({ embeds: [embed], components: [composent] });
db.set(`msg_${msg.id}`, interaction.user.id);
if (!db.has('pending_list')) {
db.set('pending_list' , [])
}
db.push('pending_list', interaction.user.id);
await interaction.reply({content: `Your request has been sended successfully , please wait !` , ephemeral: true})
}
});
client.login(process.env.TOKEN);