· 6 years ago · Jul 06, 2019, 01:06 PM
1
2client.on("message", message => {
3if(message.content.startsWith(prefix + "setnick")){
4if(message.author.bot || message.channel.type == "dm" || !message.member.hasPermission("MANAGE_NICKNAMES") || !message.guild.member(client.user).hasPermission("MANAGE_NICKNAMES")) return;
5var user = message.mentions.members.first();
6var args = message.content.split(" ").slice(2);
7var nick = args.join(" ");
8if(!user || !args) return message.channel.send(`**• | Usage:** ${prefix}setnick \`\`@Name\`\` nickname`);
9message.guild.member(user.user).setNickname(`${nick}`);
10message.channel.send(`Successfully changed **${user}** nickname to **${nick}**`);
11}
12});
13
14const SQLite = require('sqlite'); // SQLpackage
15const path = require('path'); // PATHpackage
16const invites = {}; // Codes
17
18client.on("ready", () => { // ready ?
19 client.guilds.forEach(g => { // for each guilds ?
20 g.fetchInvites().then(guildInvites => { // fetch invites ?
21 invites[g.id] = guildInvites; // push guild invites on invites ^^
22 }); // end
23}); // end
24}); // end
25SQLite.open(path.join(__dirname, 'links.sql')) // read path ?
26.then(() => { // then ?
27 console.log('Opened') // seccussfull opened
28 SQLite.run(`CREATE TABLE IF NOT EXISTS linkSysteme (code TEXT, id VARCHAR(30))`) // create table if not exisit
29}) // end
30.catch(err => console.error(err)) // on error
31
32client.on("message", async msg => { // message ?
33 if(msg.author.bot || !msg.channel.guild) return; // if bot or private return
34 if(msg.content.startsWith("رابط")) { // message content
35 let invite = await msg.channel.createInvite({ // create invites
36 maxAge: 86400, // one day // limit time for invite ^^
37 maxUses: 5 // 5 people can enter // limit users for invites ^^
38 }, `Requested by ${msg.author.tag}`).catch(console.log); // reason // end
39
40 SQLite.run(`INSERT INTO linkSysteme VALUES ('${invite.code}','${msg.author.id}')`) // insert into table
41 msg.author.send(invite ? /*seccussfull*/`**مدة الرابط : يـوم عدد استخدامات الرابط : 5 **:\n ${invite}` /*error catch*/: "يوجد خلل في البوت :( \n يتم حل المشكل قريبا ...");
42 }
43
44})
45
46let inv_room = "544475000158289920" // room id
47client.on('guildMemberAdd', async member => { // membed add event
48 member.guild.fetchInvites().then(async guildInvites => { // fetch invites ?
49 const inv = invites[member.guild.id]; // get invite :)
50 invites[member.guild.id] = guildInvites; // push guild invites on invites
51 let invite = guildInvites.find(i => inv.get(i.code).uses < i.uses); // find ?
52 let res = await SQLite.get(`SELECT * FROM linkSysteme WHERE code = '${invite.code}'`) // select from sql
53 if(!res) { // if the code does'nt exists
54 console.log(invite.code) // for test
55 client.channels.get(inv_room).send("**Welcom To "+member.guild.name+"? .\n Joined By: "+invite.inviter+".**") // send message to welcome room
56 } else { // if the code link exitst
57 client.channels.get(inv_room).send("**Welcom To "+member.guild.name+"? .\n Joined By: <@!"+res.id+">.**") // send message to welcome room
58 console.log(res.code) // for test
59 } // end if
60 }); // end fetchs :)
61}); // end events :) ) )) )) )) )) )) )) ) )) ))
62
63
64const fs = require("fs")
65const say = JSON.parse(fs.readFileSync('./say.json', 'utf8'))
66
67client.on("message", message =>
68 {
69 if(!say[message.guild.id]) say[message.guild.id] = {
70 say: 'say'
71 }
72 if(message.content.startsWith(prefix + "say" ) || message.content.startsWith(say[message.guild.id].say)) {
73 var args = message.content.split(" ").slice(1).join(" ")
74 message.channel.send(args)
75 }});
76client.on("message", message => {
77if(message.content.startsWith(prefix + 'set-say')) {
78 var args = message.content.split(" ").slice(1).join(" ")
79 if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
80 if(!say[message.guild.id]) say[message.guild.id] = {
81 say: 'say'
82 }
83 message.channel.send(`**SET THE SAY COMMAND TO ${args}**`), say[message.guild.id].say = args
84 fs.writeFile("./say.json", JSON.stringify(say), (err) => {
85 if (err) console.error(err)
86 })
87}
88})
89
90let anti = JSON.parse(fs.readFileSync("./antigreff.json", "UTF8"));
91let config = JSON.parse(fs.readFileSync("./config.json", "UTF8"));
92client.on("message", message => {
93 if (!message.channel.guild) return;
94 let user = anti[message.guild.id + message.author.id]
95 let num = message.content.split(" ").slice(2).join(" ");
96 if (!anti[message.guild.id + message.author.id]) anti[message.guild.id + message.author.id] = {
97 actions: 0
98 }
99 if (!config[message.guild.id]) config[message.guild.id] = {
100 banLimit: 3,
101 chaDelLimit: 3,
102 roleDelLimit: 3,
103 kickLimits: 3,
104 roleCrLimits: 3,
105 time: 30
106 }
107 if (message.content.startsWith(prefix + "settings limits")) {
108
109
110 if (!message.member.hasPermission('MANAGE_GUILD')) return;
111 if (message.content.startsWith(prefix + "settings limitsban")) {
112 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
113 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
114 config[message.guild.id].banLimit = num;
115 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].banLimit} **`)
116 }
117 if (message.content.startsWith(prefix + "settings limitskick")) {
118 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
119 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
120 config[message.guild.id].kickLimits = num;
121 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].kickLimits}**`)
122 }
123 if (message.content.startsWith(prefix + "settings limitsroleD")) {
124 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
125 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
126 config[message.guild.id].roleDelLimit = num;
127 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].roleDelLimit}**`)
128 }
129 if (message.content.startsWith(prefix + "settings limitsroleC")) {
130 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
131 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
132 config[message.guild.id].roleCrLimits = num;
133 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].roleCrLimits}**`)
134 }
135 if (message.content.startsWith(prefix + "settings limitschannelD")) {
136 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
137 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
138 config[message.guild.id].chaDelLimit = num;
139 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].chaDelLimit}**`)
140 }
141 if (message.content.startsWith(prefix + "settings limitstime")) {
142 if (!num) return message.channel.send("**⇏ | أرسل رقم ! **");
143 if (isNaN(num)) return message.channel.send("**⇏ | أرقام فقط ! **");
144 config[message.guild.id].time = num;
145 message.channel.send(`**⇏ | تم التغيير اِلي : ${config[message.guild.id].time}**`)
146 }
147 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
148 if (e) throw e;
149 });
150 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
151 if (e) throw e;
152 });
153 }
154});
155client.on("channelDelete", async channel => {
156 const entry1 = await channel.guild.fetchAuditLogs({
157 type: 'CHANNEL_DELETE'
158 }).then(audit => audit.entries.first())
159 console.log(entry1.executor.username)
160 const entry = entry1.executor
161 if (!config[channel.guild.id]) config[channel.guild.id] = {
162 banLimit: 3,
163 chaDelLimit: 3,
164 roleDelLimit: 3,
165 kickLimits: 3,
166 roleCrLimits: 3
167 }
168 if (!anti[channel.guild.id + entry.id]) {
169 anti[channel.guild.id + entry.id] = {
170 actions: 1
171 }
172 setTimeout(() => {
173 anti[channel.guild.id + entry.id].actions = "0"
174 }, config[channel.guild.id].time * 1000)
175 } else {
176 anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
177 console.log("TETS");
178 setTimeout(() => {
179 anti[channel.guild.id + entry.id].actions = "0"
180 }, config[channel.guild.id].time * 1000)
181 if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].chaDelLimit) {
182 channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**⇏ | ${entry.username} قام بمسح الكثير من الرومات **`))
183 anti[channel.guild.id + entry.id].actions = "0"
184 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
185 if (e) throw e;
186 });
187 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
188 if (e) throw e;
189 });
190 }
191 }
192
193 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
194 if (e) throw e;
195 });
196 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
197 if (e) throw e;
198 });
199});
200
201client.on("roleDelete", async channel => {
202 const entry1 = await channel.guild.fetchAuditLogs({
203 type: 'ROLE_DELETE'
204 }).then(audit => audit.entries.first())
205 console.log(entry1.executor.username)
206 const entry = entry1.executor
207 if (!config[channel.guild.id]) config[channel.guild.id] = {
208 banLimit: 3,
209 chaDelLimit: 3,
210 roleDelLimit: 3,
211 kickLimits: 3,
212 roleCrLimits: 3
213 }
214 if (!anti[channel.guild.id + entry.id]) {
215 anti[channel.guild.id + entry.id] = {
216 actions: 1
217 }
218 setTimeout(() => {
219 anti[channel.guild.id + entry.id].actions = "0"
220 }, config[channel.guild.id].time * 1000)
221 } else {
222 anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
223 console.log("TETS");
224 setTimeout(() => {
225 anti[channel.guild.id + entry.id].actions = "0"
226 }, config[channel.guild.id].time * 1000)
227 if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleDelLimit) {
228 channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**⇏ | ${entry.username} قام بمسح الكثير من الرتب **`))
229 anti[channel.guild.id + entry.id].actions = "0"
230 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
231 if (e) throw e;
232 });
233 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
234 if (e) throw e;
235 });
236 }
237 }
238
239 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
240 if (e) throw e;
241 });
242 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
243 if (e) throw e;
244 });
245});
246
247client.on("roleCreate", async channel => {
248 const entry1 = await channel.guild.fetchAuditLogs({
249 type: 'ROLE_CREATE'
250 }).then(audit => audit.entries.first())
251 console.log(entry1.executor.username)
252 const entry = entry1.executor
253 if (!config[channel.guild.id]) config[channel.guild.id] = {
254 banLimit: 3,
255 chaDelLimit: 3,
256 roleDelLimit: 3,
257 kickLimits: 3,
258 roleCrLimits: 3
259 }
260 if (!anti[channel.guild.id + entry.id]) {
261 anti[channel.guild.id + entry.id] = {
262 actions: 1
263 }
264 setTimeout(() => {
265 anti[channel.guild.id + entry.id].actions = "0"
266 }, config[channel.guild.id].time * 1000)
267 } else {
268 anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
269 console.log("TETS");
270 setTimeout(() => {
271 anti[channel.guild.id + entry.id].actions = "0"
272 }, config[channel.guild.id].time * 1000)
273 if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleCrLimits) {
274 channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**⇏ | ${entry.username} قام بأنشاء الكثير من الرتب **`))
275 anti[channel.guild.id + entry.id].actions = "0"
276 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
277 if (e) throw e;
278 });
279 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
280 if (e) throw e;
281 });
282 }
283 }
284
285 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
286 if (e) throw e;
287 });
288 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
289 if (e) throw e;
290 });
291});
292
293client.on("guildBanAdd", async (guild, user) => {
294 const entry1 = await channel.guild.fetchAuditLogs({
295 type: 'MEMBER_BAN_ADD'
296 }).then(audit => audit.entries.first())
297 console.log(entry1.executor.username)
298 const entry = entry1.executor
299 if (!config[guild.id]) config[guild.id] = {
300 banLimit: 3,
301 chaDelLimit: 3,
302 roleDelLimit: 3,
303 kickLimits: 3,
304 roleCrLimits: 3
305 }
306 if (!anti[guild.id + entry.id]) {
307 anti[guild.id + entry.id] = {
308 actions: 1
309 }
310 setTimeout(() => {
311 anti[guild.id + entry.id].actions = "0"
312 }, config[guild.id].time * 1000)
313 } else {
314 anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
315 console.log("TETS");
316 setTimeout(() => {
317 anti[guild.id + entry.id].actions = "0"
318 }, config[guild.id].time * 1000)
319 if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
320 channel.members.get(entry.id).ban().catch(e => channel.owner.send(`**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`))
321 anti[guild.id + entry.id].actions = "0"
322 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
323 if (e) throw e;
324 });
325 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
326 if (e) throw e;
327 });
328 }
329 }
330
331 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
332 if (e) throw e;
333 });
334 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
335 if (e) throw e;
336 });
337});
338
339client.on("guildKickAdd", async (guild, user) => {
340 const entry1 = await channel.fetchAuditLogs({
341 type: 'MEMBER_KICK'
342 }).then(audit => audit.entries.first())
343 console.log(entry1.executor.username)
344 const entry = entry1.executor
345 if (!config[guild.id]) config[guild.id] = {
346 banLimit: 3,
347 chaDelLimit: 3,
348 roleDelLimit: 3,
349 kickLimits: 3,
350 roleCrLimits: 3
351 }
352 if (!anti[guild.id + entry.id]) {
353 anti[guild.id + entry.id] = {
354 actions: 1
355 }
356 setTimeout(() => {
357 anti[guild.id + entry.id].actions = "0"
358 }, config[guild.id].time * 1000)
359 } else {
360 anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
361 console.log("TETS");
362 setTimeout(() => {
363 anti[guild.id + entry.id].actions = "0"
364 }, config[guild.id].time * 1000)
365 if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
366 channel.members.get(entry.id).ban().catch(e => channel.owner.send(`**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`))
367 anti[guild.id + entry.id].actions = "0"
368 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
369 if (e) throw e;
370 });
371 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
372 if (e) throw e;
373 });
374 }
375 }
376
377 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
378 if (e) throw e;
379 });
380 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
381 if (e) throw e;
382 });
383});
384
385client.on("guildMemberRemove", async member => {
386 const entry1 = await member.guild.fetchAuditLogs().then(audit => audit.entries.first())
387 if (entry1.action === "MEMBER_KICK") {
388 const entry2 = await member.guild.fetchAuditLogs({
389 type: "MEMBER_KICK"
390 }).then(audit => audit.entries.first())
391 const entry = entry2.executor;
392 if (!config[member.guild.id]) config[guild.id] = {
393 banLimit: 3,
394 chaDelLimit: 3,
395 roleDelLimit: 3,
396 kickLimits: 3,
397 roleCrLimits: 3
398 }
399 if (!anti[member.guild.id + entry.id]) {
400 anti[member.guild.id + entry.id] = {
401 actions: 1
402 }
403 setTimeout(() => {
404 anti[member.guild.id + entry.id].actions = "0"
405 }, config[member.guild.id].time * 1000)
406 } else {
407 anti[member.guild.id + entry.id].actions = Math.floor(anti[member.guild.id + entry.id].actions + 1)
408 console.log("TETS");
409 setTimeout(() => {
410 anti[member.guild.id + entry.id].actions = "0"
411 }, config[member.guild.id].time * 1000)
412 if (anti[member.guild.id + entry.id].actions >= config[member.guild.id].kickLimits) {
413 member.members.get(entry.id).ban().catch(e => member.owner.send(`**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`))
414 anti[member.guild.id + entry.id].actions = "0"
415 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
416 if (e) throw e;
417 });
418 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
419 if (e) throw e;
420 });
421 }
422 }
423
424 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
425 if (e) throw e;
426 });
427 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
428 if (e) throw e;
429 });
430 }
431
432})
433
434
435
436
437//antigreff.json
438//config.json
439
440client.on("message", message => { //iTzMurtaja
441 if(message.content.startsWith(prefix + "emoji")) { //iTzMurtaja
442 if(message.author.bot) return; //iTzMurtaja
443 var emojiid = message.content.split(" ").slice(1).join(" ") //iTzMurtaja
444 console.log(emojiid) //iTzMurtaja
445 if(emojiid.length < "18" || emojiid.length > "18" || isNaN(emojiid)) return message.channel.send(`- Usage
446${prefix}emoji <EmojiID>`); //iTzMurtaja
447 else //iTzMurtaja
448 message.channel.send("This is the emoji that you requested:-",
449 { //iTzMurtaja
450 files: [`https://cdn.discordapp.com/emojis/${emojiid}.png`]
451 }) //iTzMurtaja
452 } //iTzMurtaja
453
454client.on("message", msg => {
455 if (msg == ${prefix}check) {
456 let guild = client.guilds.find(g => g.ownerID == msg.author.id)//MohamedTarek
457 if(!guild) return msg.channel.send("❌ No guilds for you, Try again.")//MohamedTarek
458 msg.channel.send("? Congratulations, you get a role.")//MohamedTarek
459 client.guilds.get("SupportServerID").member(msg.author.id).addRole(client.guilds.get("SupportServerID").roles.get("GuestRoleID"));
460 }
461});//MohamedTarek