-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
244 lines (216 loc) · 11.2 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
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
function on(discord, client, mongo, Joi){
client.on('message', async message => {
const prefix = `<@!${client.user.id}>`;
const enterVanityCode = new discord.MessageEmbed()
.setTitle(`Hi There, ${message.author.tag}`)
.setDescription("**Getting Started**\n\nEncrypt your server with **Sandy**. It allows you to verify every user that joins your server. Click [here](https://brawley.js.org) to learn more.\n\n`You'll have to choose a vanity code (where users can verify themselves) and send it here in this channel (You Have 15 Seconds).`")
.setTimestamp()
.setFooter('https://brawley.js.org');
const typeConfirm = new discord.MessageEmbed()
.setDescription("**Accept The Service Rules**\n\n**#1.** Abide by the Terms of Service\n**Discord :** https://discord.com/terms\n**Sandy :** https://brawley.js.org \n\n**#2.** Don't defeat the purpose, please don't use this service if you don't need it. This server shouldn't have any invite links so users couldn't access without verification.\n\n**#4.** We have rights to collect any data from this server.\n\n**Type** `accept` **to accept the rules**");
const securityLevel = new discord.MessageEmbed()
.setTitle('Choose A Security Level')
.setDescription('**Strict Levels :**\n\n\n**1 : Members must have a verified email on their Discord account.**\n\n**2 : Members must also be registered on Discord for longer than `x` minutes. ( Please specify )**\n\n**3 : Members must also join at least 3 servers.**\n\n**4 : Members must also use the password to join. ( Please specify )**\n\n**5 : Members must also register their account with specific domain name. ( Please specify )**\n\nPlease reply with **Numbers** ( 1-4 ). If you choose level 2 and above, you should reply with something like this :\n```fix\n5|10|password|example.com```');
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(' '),
command = args.shift().toLowerCase(),
db = await mongo.findOne({ guildID: message.guild.id });
if (command == "setup") { /* 1 */
if (message.member.hasPermission('ADMINISTRATOR')) { /* 2 */
if (!db) { /* 3 */
message.ireply(enterVanityCode).then((m) => { /* 4 */
const filter = m => m.content;
const collector1 = message.channel.createMessageCollector(filter, { time: 15000 });
collector1.on('collect', async a => { /* 5 */
const vanity = a.content;
const check = await mongo.findOne({ vanity: vanity });
if (check) {
message.ireply('This Vanity Link Was Exist, Please Try Again');
} else { /* 6 */
collector1.stop();
m.edit(securityLevel).then((b) => { /* 7 */
const filter = b => b.content;
const collector2 = message.channel.createMessageCollector(filter, { time: 30000 });
collector2.on('collect', async c => { /* 8 */
if (c.content) { /* 9 */
collector2.stop();
let object;
const options = c.content.split("|");
if (options[0] < 1 || options[0] > 5) {
return m.edit({ embed: { description: '**Please Specify A Security Level Between 1 - 5 **' } });
}
if (options[0] == "2" && options.length < 2) {
return m.edit({ embed: { description: '**Please Specify x minutes**' } });
}
if (options[0] == "3" && options.length < 2) {
return m.edit({ embed: { description: '**Please Specify x minutes**' } });
}
if (options[0] == "4" && options.length < 3) {
return m.edit({ embed: { description: '**Please Specify a password & x minutes**' } });
}
if (options[0] == "5" && options.length < 4) {
return m.edit({ embed: { description: '**Please Specify x minutes, password & email domain name**' } });
}
if (options[0] == "5" && options.length > 3) {
let schema5 = Joi.object({
level: Joi.number().required().min(5).max(5),
mins: Joi.number().required().min(1),
requiredServer: Joi.number().required().min(3).max(3),
domain: Joi.string().domain({ tlds: true }).required(),
password: Joi.string().required()
})
object = {
level: options[0],
mins: options[1],
domain: options[3],
requiredServer: 3,
password: options[2]
}
try {
await schema5.validateAsync(object);
} catch (e) {
console.log(e)
return m.edit({ embed: { description: '**Something Went Wrong**' } });
}
}
if (options[0] == "4" && options.length > 2) {
let schema4 = Joi.object({
level: Joi.number().required().min(4).max(4),
mins: Joi.number().required().min(1),
requiredServer: Joi.number().required().min(3).max(3),
password: Joi.string().required()
})
object = {
level: options[0],
mins: options[1],
requiredServer: 3,
password: options[2]
}
try {
await schema4.validateAsync(object);
} catch (e) {
console.log(e)
return m.edit({ embed: { description: '**Something Went Wrong**' } });
}
}
if (options[0] == "3" && options.length > 1) {
let schema3 = Joi.object({
level: Joi.number().required().min(1).max(4),
mins: Joi.number().required().min(1),
requiredServer: Joi.number().required().min(3).max(3)
})
object = {
level: options[0],
mins: options[1],
requiredServer: 3
}
try {
await schema3.validateAsync(object);
} catch (e) {
return m.edit({ embed: { description: '**Something Went Wrong**' } });
}
}
if (options[0] == "2" && options.length > 1) {
let schema2 = Joi.object({
level: Joi.number().required().min(1).max(4),
mins: Joi.number().required().min(1)
});
object = {
level: options[0],
mins: options[1],
}
try {
await schema2.validateAsync(object);
} catch (e) {
return m.edit('**Something Went Wrong**');
}
}
if (options[0] == "1") {
object = {
level: options[0],
}
let schema1 = Joi.object({
level: Joi.number().required().min(1).max(4),
});
try {
await schema1.validateAsync(object);
} catch (e) {
return m.edit({ embed: { description: '**Something Went Wrong**' } })
}
}
if (options[0] == "2" && options[1] == '') {
return m.edit({ embed: { description: '**Please specify x minutes**' } })
}
if (options[0] == "3" && options[1] == '') {
return m.edit({ embed: { description: '**Please specify x minutes**' } })
}
if (options[0] == "4" && options[1 || 2] == '') {
return m.edit({ embed: { description: '**Please specify x minutes, password**' } })
}
if (options[0] == "5" && options[1 || 2 || 3] == '') {
return m.edit({ embed: { description: '**Please specify x minutes, password & email domain name**' } })
}
if (!object) {
return m.edit({ embed: { description: '**Something Went Wrong**' } });
}
m.edit(typeConfirm).then((d) => { /* 10 */
const newGuild = new mongo({
guildID: message.guild.id,
userID: message.author.id,
vanity: vanity,
option: object,
lastUpdated: new Date()
});
const filter = d => d.content.toLowerCase().includes('accept');
const collector3 = message.channel.createMessageCollector(filter, { time: 15000 });
collector3.on('collect', async f => {/* 12 */
if (f.content.toLowerCase() == "accept") {
newGuild.save().then((res) => { /* 13 */
console.log(res);
collector3.stop();
m.edit({ embed: { description: `**Setup successfully !**\n\n Now you may use https://brawley.js.org/invite/${res.vanity} as your primary server invite link.` } });
})/* 13 */
}
}) /* 12 */
}) /* 10 */
} /* 9 */
}) /* 8 */
}) /* 7 */
}/* 6 */
}) /* 5 */
})/* 4 */
} else {
message.ireply('exist')
} /* 3 */
} /* 2 */
} /* 1 */
if (command == "raze") {
if (message.member.hasPermission('ADMINISTRATOR')) {
if (!db) {
message.reply("You Haven't Setup Yet")
} else {
message.ireply('Are you sure, type confirm to confirm').then((m) => {
const filter = m => m.content
const collector = message.channel.createMessageCollector(filter, { time: 15000 });
collector.on('collect', m => {
if (m.content.toLowerCase() == "confirm") {
mongo.deleteOne({ guildID: message.guild.id }).then(() => {
message.ireply('Alright, Deleted')
})
collector.stop()
} else {
message.ireply('Seems Like You Have Changed Your Mind')
collector.stop()
}
})
})
}
}
}
})
client.on('ready', () => {
console.log(client.user.tag)
client.user.setActivity('Firewall', { type: 'PLAYING' });
});
}
module.exports = on;