forked from 6--/ShinobiBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.py
1141 lines (1100 loc) · 80.7 KB
/
logs.py
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import discord
from discord import app_commands
from discord.ext import commands
import aiosqlite
#edits confirm button
class editsConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def edits_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != edits_log_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_messages_edits.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (edits_log_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (edits_log_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Edited Messages Log", description = "Your edited messages log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def edits_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != edits_log_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
#deletes confirm button
class deletesConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def deletes_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != deletes_log_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_messages_deletes.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (deletes_log_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (deletes_log_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Deleted Messages Log", description = "Your deleted messages log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def deletes_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != deletes_log_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
#joins confirm button
class joinsConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def joins_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != joins_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_joins.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (joins_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (joins_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Joins Log", description = "Your members' joins log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def joins_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != joins_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
#leaves confirm button
class leavesConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def leaves_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != leaves_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_leaves.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (leaves_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (leaves_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Leaves Log", description = "Your members' leaves log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def leaves_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != leaves_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# role create confirm button
class roleCreateConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def role_create_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_create_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_role_create.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (roles_create_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (roles_create_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Create Log", description = "Your role create log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def role_create_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_create_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# role delete confirm button
class roleDeleteConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def role_delete_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_delete_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_role_delete.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (roles_delete_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (roles_delete_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Delete Log", description = "Your role delete log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def role_delete_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_delete_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# role update confirm button
class roleUpdatesConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def role_update_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_role_updates.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (roles_updates_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (roles_updates_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Updates Log", description = "Your role updates log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def role_update_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# role given confirm button
class roleGivenConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def role_given_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_given_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_role_given.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (roles_given_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (roles_given_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Given Log", description = "Your role given log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def role_given_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_given_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# role remove confirm button
class roleRemoveConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def role_leave_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_removed_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_role_remove.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (roles_removed_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (roles_removed_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Remove Log", description = "Your role remove log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def role_remove_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != roles_removed_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# member ban confirm button
class memberBanConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def member_ban_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_ban_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_member_ban.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (member_ban_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (member_ban_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Ban Log", description = "Your member ban log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def member_ban_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_ban_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# member unban confirm button
class memberUnbanConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def member_unban_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_unban_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_member_unban.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (member_unban_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (member_unban_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Unban Log", description = "Your member unban log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def member_unban_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_unban_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# member timeout confirm button
class memberTimeoutConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def member_timeout_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_timeout_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_member_timeout.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (member_timeout_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (member_timeout_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Timeout Log", description = "Your member timeout log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def member_timeout_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != member_timeout_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# nickname change confirm button
class nicknameChangeConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def nickname_change_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != nickname_change_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_nickname_change.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (nickname_change_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (nickname_change_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Nickname Change Log", description = "Your nickname change log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def nickname_change_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != nickname_change_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# channel create confirm button
class channelCreateConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def channel_create_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_create_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_channel_create.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (channel_create_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (channel_create_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Channel Create Log", description = "Your channel create log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def channel_create_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_create_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# channel delete confirm button
class channelDeleteConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def channel_delete_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_delete_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_channel_delete.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (channel_delete_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (channel_delete_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Channel Delete Log", description = "Your channel delete log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def channel_delete_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_delete_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# channel updates confirm button
class channelUpdatesConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def channel_updates_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_channel_updates.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (channel_updates_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (channel_updates_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Channel Updates Log", description = "Your channel updates log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def channel_updates_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != channel_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# server updates confirm button
class serverUpdatesConfirm(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
async def server_updates_confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != server_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
async with aiosqlite.connect("db/log_server_updates.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("UPDATE log SET channel = ? WHERE guild = ?", (server_updates_channel, interaction.guild.id,))
else: await cursor.execute("INSERT INTO log (channel, guild) VALUES (?, ?)", (server_updates_channel, interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Server Updates Log", description = "Your server updates log channel has been updated succesfully!", color = 0x000000)
await interaction.response.send_message(embed = embed)
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
#cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.red)
async def server_updates_cancel(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != server_updates_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# server updates confirm button
class ConfirmDisableAll(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.danger)
async def confirm_disable_all(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != disable_all_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
await interaction.response.defer()
logs_files_list = ["joins", "leaves", "messages_edits", "messages_deletes", "role_create", "role_delete", "role_updates", "role_given", "role_remove",
"channel_create", "channel_delete", "channel_updates", "member_ban", "member_unban", "member_timeout" ,"nickname_change", "server_updates"]
for log_file in logs_files_list:
async with aiosqlite.connect(f"db/log_{log_file}.db") as db:
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
await db.commit()
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.followup.send("All logs have been disabled successfully.")
# cancel button
@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.gray)
async def cancel_disable_all(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != disable_all_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
await interaction.response.send_message("Process Canceled.")
# disable all settings confirm button
class DisableAll(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout = timeout)
@discord.ui.button(label = "Disable All", style = discord.ButtonStyle.red)
async def disable_all(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != disable_all_author: return await interaction.response.send_message("This is not for you!", ephemeral = True)
embed = discord.Embed(title = "Disabling all logs", description = "Are you sure that you want to disable all logs in this server?", color = discord.Colour.red())
await interaction.response.send_message(embed = embed, view = ConfirmDisableAll())
for child in self.children:
child.disabled = True
await interaction.message.edit(view = self)
# Logs Class
class Logs(commands.GroupCog, name = "log"):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
super().__init__()
# Defining sub-groups
messages_group = app_commands.Group(name = "message", description = "Log messages")
roles_group = app_commands.Group(name = "role", description = "Log roles")
members_group = app_commands.Group(name = "member", description = "Log member")
channels_group = app_commands.Group(name = "channel", description = "Log channels")
# show settings command
@app_commands.command(name = "show_settings", description = "Show current settings for all logs commands.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def show_settings(self, interaction: discord.Interaction):
global disable_all_author
disable_all_author = interaction.user
log_channels_list = []
logs_files_list = ["channel_create", "channel_delete", "channel_updates", "member_ban", "member_unban", "member_timeout", "nickname_change",
"messages_edits", "messages_deletes", "role_create", "role_delete", "role_updates", "role_given", "role_remove",
"server_updates", "joins", "leaves"]
is_all_disabled = True
for log_file in logs_files_list:
async with aiosqlite.connect(f"db/log_{log_file}.db") as db:
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data: log_channels_list.append(self.bot.get_channel(data[0]).mention)
else: log_channels_list.append("Disabled")
embed = discord.Embed(title = "Logs Settings", description = "All current settings", color = 0x000000)
embed.add_field(name = "Channel Create", value = log_channels_list[0])
embed.add_field(name = "Channel Delete", value = log_channels_list[1])
embed.add_field(name = "Channel Updates", value = log_channels_list[2])
embed.add_field(name = "Member Ban", value = log_channels_list[3])
embed.add_field(name = "Member Unban", value = log_channels_list[4])
embed.add_field(name = "Member Timeout", value = log_channels_list[5])
embed.add_field(name = "Member Nickname", value = log_channels_list[6])
embed.add_field(name = "Message Edits", value = log_channels_list[7])
embed.add_field(name = "Message Deletes", value = log_channels_list[8])
embed.add_field(name = "Role Create", value = log_channels_list[9])
embed.add_field(name = "Role Delete", value = log_channels_list[10])
embed.add_field(name = "Role Updates", value = log_channels_list[11])
embed.add_field(name = "Role Given", value = log_channels_list[12])
embed.add_field(name = "Role Remove", value = log_channels_list[13])
embed.add_field(name = "Server Updates", value = log_channels_list[14])
embed.add_field(name = "Joins", value = log_channels_list[15])
embed.add_field(name = "Leaves", value = log_channels_list[16])
await interaction.response.send_message(embed = embed, view = DisableAll())
#joins command
@app_commands.command(name = "joins", description = "Log members' joins and send them to a channel.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def joins(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_joins.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Joins Log", description = "Your members' joins log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Members' joins log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global joins_author
global joins_channel
joins_author = interaction.user
joins_channel = channel.id
view = joinsConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your joins log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
#leaves command
@app_commands.command(name = "leaves", description = "Log members' leaves and send them to a channel.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def leaves(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_leaves.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Leaves Log", description = "Your members' leaves log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Members' joins log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global leaves_author
global leaves_channel
leaves_author = interaction.user
leaves_channel = channel.id
view = leavesConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your leaves log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
#log msg edit command
@messages_group.command(name = "edits", description = "Log edited messages and send them to a channel.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def msg_edits(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_messages_edits.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Edited Messages Log", description = "Your edited messages log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Edited messages' log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global edits_log_author
global edits_log_channel
edits_log_author = interaction.user
edits_log_channel = channel.id
view = editsConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your edited messages log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
#log msg delete command
@messages_group.command(name = "deletes", description = "Log deleted messages and send them to a channel.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def msg_deletes(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_messages_deletes.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Deleted Messages Log", description = "Your deleted messages log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Deleted messages' log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global deletes_log_author
global deletes_log_channel
deletes_log_author = interaction.user
deletes_log_channel = channel.id
view = deletesConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your deleted messages log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# role create command
@roles_group.command(name = "create", description = "Log roles when created.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def role_create(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_role_create.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Create Log", description = "Your role created log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Roles create log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global roles_create_author
global roles_create_channel
roles_create_author = interaction.user
roles_create_channel = channel.id
view = roleCreateConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your roles create log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# role delete command
@roles_group.command(name = "delete", description = "Log roles when deleted.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def role_delete(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_role_delete.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Delete Log", description = "Your role deleted log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Roles delete log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global roles_delete_author
global roles_delete_channel
roles_delete_author = interaction.user
roles_delete_channel = channel.id
view = roleDeleteConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your roles delete log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# role update command
@roles_group.command(name = "updates", description = "Log roles when updated. (name, permissions)")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def role_update(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_role_updates.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Updates Log", description = "Your role updates log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Roles updates log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global roles_updates_author
global roles_updates_channel
roles_updates_author = interaction.user
roles_updates_channel = channel.id
view = roleUpdatesConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your roles updates log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# role given command
@roles_group.command(name = "given", description = "Log roles when given to a member.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def role_given(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_role_given.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Given Log", description = "Your given role log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Roles given log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global roles_given_author
global roles_given_channel
roles_given_author = interaction.user
roles_given_channel = channel.id
view = roleGivenConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your roles given log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# role removed command
@roles_group.command(name = "remove", description = "Log roles when remove from a member.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def role_remove(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_role_remove.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Role Removed Log", description = "Your removed role log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Roles removed log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global roles_removed_author
global roles_removed_channel
roles_removed_author = interaction.user
roles_removed_channel = channel.id
view = roleRemoveConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your roles removed log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# member ban command
@members_group.command(name = "ban", description = "Log member bans.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def memebr_ban(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_member_ban.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Ban Log", description = "Your member ban log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Member ban log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global member_ban_author
global member_ban_channel
member_ban_author = interaction.user
member_ban_channel = channel.id
view = memberBanConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your member ban log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# member unban command
@members_group.command(name = "unban", description = "Log member unbans.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def memebr_unban(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_member_unban.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Unban Log", description = "Your member unban log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Member unban log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global member_unban_author
global member_unban_channel
member_unban_author = interaction.user
member_unban_channel = channel.id
view = memberUnbanConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your member unban log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# member timeout command
@members_group.command(name = "timeout", description = "Log member timeout.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def memebr_timeout(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_member_timeout.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Member Timeout Log", description = "Your member timeout log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Member timeout log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":
if channel == None: return await interaction.response.send_message("You must include a channel to set the log.", ephemeral = True)
global member_timeout_author
global member_timeout_channel
member_timeout_author = interaction.user
member_timeout_channel = channel.id
view = memberTimeoutConfirm()
em = discord.Embed(title = "Confirmation",
description = f"Are you sure that you want {channel.mention} to be your member timeout log channel?",
colour = 0x2F3136)
await interaction.response.send_message(embed = em, view = view)
# nickname change command
@members_group.command(name = "nickname", description = "Log nickname change.")
@app_commands.checks.has_permissions(manage_channels = True)
@app_commands.describe(switch = "Enable/Disable log.", channel = "Channel to send the log.")
@app_commands.choices(switch = [app_commands.Choice(name = "enable", value = "enable"), app_commands.Choice(name = "disable", value = "disable")])
@app_commands.checks.cooldown(1, 10, key = lambda i: (i.user.id))
async def nickname_change(self, interaction: discord.Interaction, switch: app_commands.Choice[str], channel: discord.TextChannel = None):
if switch.value == "disable":
async with aiosqlite.connect("db/log_nickname_change.db") as db: # Open the db
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS log (channel INTEGER, guild ID)")
await cursor.execute("SELECT channel FROM log WHERE guild = ?", (interaction.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute("DELETE FROM log WHERE guild = ?", (interaction.guild.id,))
embed = discord.Embed(title = "📝 ┃ Nickname Change Log", description = "Your nickname change log has been disabled succesfully.", color = 0x000000)
await interaction.response.send_message(embed = embed)
else:
await interaction.response.send_message("Nickname change log is already disabled in your server.", ephemeral = True)
await db.commit()
if switch.value == "enable":