File size: 41,980 Bytes
101cf29
04d2623
9bf4e97
04d2623
1327cc8
b55b028
 
1add7fb
04d2623
 
3c7624f
 
 
 
a84eaf5
 
 
3c7624f
 
a84eaf5
04d2623
 
1add7fb
04d2623
 
9bf4e97
 
 
 
04d2623
9bf4e97
 
04d2623
9bf4e97
 
04d2623
 
9bf4e97
04d2623
 
9bf4e97
 
 
04d2623
9bf4e97
 
 
 
 
 
 
 
 
 
1add7fb
9bf4e97
1add7fb
 
9bf4e97
 
 
 
1add7fb
9bf4e97
 
 
 
 
 
 
 
 
 
 
 
 
1add7fb
9bf4e97
1add7fb
 
9bf4e97
 
 
 
1add7fb
9bf4e97
1add7fb
 
9bf4e97
 
 
 
1add7fb
9bf4e97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1add7fb
9bf4e97
 
 
 
 
 
 
1add7fb
1a2aa65
b55b028
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470abe0
 
 
 
 
 
7e0aed7
 
 
 
 
470abe0
 
 
 
 
 
 
b270d02
470abe0
 
 
8da1f58
 
 
 
 
470abe0
8da1f58
470abe0
 
b270d02
470abe0
 
 
 
62ffcc1
 
d440890
 
8da1f58
 
d440890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62ffcc1
 
 
d440890
 
 
 
b270d02
d440890
 
62ffcc1
470abe0
62ffcc1
470abe0
 
62ffcc1
470abe0
62ffcc1
470abe0
62ffcc1
470abe0
62ffcc1
7e0aed7
470abe0
 
 
 
 
 
7e0aed7
470abe0
 
 
 
 
 
 
 
 
 
 
 
 
7e0aed7
470abe0
 
 
 
 
 
7e0aed7
470abe0
 
 
 
 
7e0aed7
470abe0
 
 
 
 
7e0aed7
470abe0
 
 
 
 
7e0aed7
470abe0
 
 
 
 
7e0aed7
470abe0
 
 
 
 
 
62ffcc1
7e0aed7
 
 
62ffcc1
 
470abe0
 
 
 
 
 
 
 
 
 
62ffcc1
 
 
 
 
470abe0
 
 
 
b270d02
7e0aed7
 
470abe0
 
 
 
b270d02
470abe0
b270d02
470abe0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62ffcc1
7e0aed7
470abe0
 
7e0aed7
 
470abe0
7e0aed7
 
 
1327cc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2866b19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9bf4e97
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
import asyncio
import discord
from discord import app_commands
import os
import json
import random
import re
from datetime import timedelta
from dotenv import load_dotenv

if os.path.exists(".donotasktoken"):
    load_dotenv()
    TOKEN = os.getenv("DISCORD_TOKEN")
else:
    TOKEN = input("Podaj token Discorda: ").strip()
    with open(".env", "w") as f:
        f.write(f"DISCORD_TOKEN={TOKEN}\n")
    open(".donotasktoken", "w").close()
    print("Token zapisany. Nastepnym razem bedzie uzyty automatycznie.")

intents = discord.Intents.default()
intents.message_content = True
intents.members = True


class BotDC(discord.Client):
    def __init__(self):
        super().__init__(intents=intents)
        self.tree = app_commands.CommandTree(self)

    async def setup_hook(self):
        await self.tree.sync()

    async def on_ready(self):
        print(f"Zalogowano jako {self.user}")


bot = BotDC()


@bot.tree.command(name="ping", description="Sprawdza czy bot odpowiada")
async def ping(interaction: discord.Interaction):
    await interaction.response.send_message("Pong!")


@bot.tree.command(name="hello", description="Wita użytkownika")
async def hello(interaction: discord.Interaction):
    await interaction.response.send_message(f"Cześć {interaction.user.mention}!")


@bot.tree.command(name="kick", description="Wyrzuca użytkownika")
@app_commands.describe(member="Użytkownik do wyrzucenia", reason="Powód")
@app_commands.default_permissions(kick_members=True)
async def kick(interaction: discord.Interaction, member: discord.Member, reason: str = "Nie podano powodu"):
    await member.kick(reason=reason)
    await interaction.response.send_message(f"👍 Wyrzucono {member.mention}. Powód: {reason}")


@bot.tree.command(name="ban", description="Banuje użytkownika")
@app_commands.describe(member="Użytkownik do zbanowania", reason="Powód")
@app_commands.default_permissions(ban_members=True)
async def ban(interaction: discord.Interaction, member: discord.Member, reason: str = "Nie podano powodu"):
    await member.ban(reason=reason)
    await interaction.response.send_message(f"👍 Zbanowano {member.mention}. Powód: {reason}")


@bot.tree.command(name="unban", description="Odbanowuje użytkownika")
@app_commands.describe(user="Nazwa użytkownika (np. user#1234)")
@app_commands.default_permissions(ban_members=True)
async def unban(interaction: discord.Interaction, user: str):
    banned = [u async for u in interaction.guild.bans()]
    name, discrim = user.split("#")
    entry = next((u for u in banned if u.user.name == name and u.user.discriminator == discrim), None)
    if entry:
        await interaction.guild.unban(entry.user)
        await interaction.response.send_message(f"👍 Odbanowano {entry.user}")
    else:
        await interaction.response.send_message("❌ Nie znaleziono użytkownika")


@bot.tree.command(name="timeout", description="Wycisza użytkownika na X minut")
@app_commands.describe(member="Użytkownik", minutes="Liczba minut", reason="Powód")
@app_commands.default_permissions(moderate_members=True)
async def timeout(interaction: discord.Interaction, member: discord.Member, minutes: int, reason: str = "Nie podano powodu"):
    await member.timeout(discord.utils.utcnow() + timedelta(minutes=minutes), reason=reason)
    await interaction.response.send_message(f"👍 Wyciszono {member.mention} na {minutes} min. Powód: {reason}")


@bot.tree.command(name="untimeout", description="Cofa wyciszenie")
@app_commands.describe(member="Użytkownik")
@app_commands.default_permissions(moderate_members=True)
async def untimeout(interaction: discord.Interaction, member: discord.Member):
    await member.timeout(None)
    await interaction.response.send_message(f"👍 Cofnięto wyciszenie {member.mention}")


@bot.tree.command(name="clear", description="Usuwa wiadomości")
@app_commands.describe(amount="Liczba wiadomości do usunięcia")
@app_commands.default_permissions(manage_messages=True)
async def clear(interaction: discord.Interaction, amount: int):
    await interaction.channel.purge(limit=amount)
    await interaction.response.send_message(f"👍 Usunięto {amount} wiadomości", delete_after=5)


@bot.tree.command(name="lock", description="Blokuje kanał")
@app_commands.describe(channel="Kanał do zablokowania (opcjonalnie)")
@app_commands.default_permissions(manage_channels=True)
async def lock(interaction: discord.Interaction, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    await channel.set_permissions(interaction.guild.default_role, send_messages=False)
    await interaction.response.send_message(f"🔒 Zablokowano {channel.mention}")


@bot.tree.command(name="unlock", description="Odblokowuje kanał")
@app_commands.describe(channel="Kanał do odblokowania (opcjonalnie)")
@app_commands.default_permissions(manage_channels=True)
async def unlock(interaction: discord.Interaction, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    await channel.set_permissions(interaction.guild.default_role, send_messages=True)
    await interaction.response.send_message(f"🔓 Odblokowano {channel.mention}")


@bot.tree.command(name="userinfo", description="Pokazuje informacje o użytkowniku")
@app_commands.describe(member="Użytkownik (opcjonalnie)")
async def userinfo(interaction: discord.Interaction, member: discord.Member = None):
    member = member or interaction.user
    embed = discord.Embed(title=f"{member}", color=member.color)
    embed.set_thumbnail(url=member.display_avatar.url)
    embed.add_field(name="ID", value=member.id, inline=True)
    embed.add_field(name="Dołączył", value=member.joined_at.strftime("%Y-%m-%d"), inline=True)
    embed.add_field(name="Konto utworzone", value=member.created_at.strftime("%Y-%m-%d"), inline=True)
    embed.add_field(name="Role", value=" ".join(r.mention for r in member.roles[1:]) or "Brak", inline=False)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="serverinfo", description="Pokazuje informacje o serwerze")
async def serverinfo(interaction: discord.Interaction):
    guild = interaction.guild
    embed = discord.Embed(title=guild.name, color=discord.Color.blue())
    if guild.icon:
        embed.set_thumbnail(url=guild.icon.url)
    embed.add_field(name="Właściciel", value=guild.owner.mention, inline=True)
    embed.add_field(name="Członkowie", value=guild.member_count, inline=True)
    embed.add_field(name="Kanały", value=len(guild.channels), inline=True)
    embed.add_field(name="Role", value=len(guild.roles), inline=True)
    embed.add_field(name="Utworzony", value=guild.created_at.strftime("%Y-%m-%d"), inline=True)
    embed.add_field(name="ID", value=guild.id, inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="avatar", description="Pokazuje avatar użytkownika")
@app_commands.describe(member="Użytkownik (opcjonalnie)")
async def avatar(interaction: discord.Interaction, member: discord.Member = None):
    member = member or interaction.user
    embed = discord.Embed(title=f"Avatar {member.display_name}", color=member.color)
    embed.set_image(url=member.display_avatar.url)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="roll", description="Rzuca kostką np. /roll 2d6")
@app_commands.describe(dice="np. 2d6, d20, 3d8+2")
async def roll(interaction: discord.Interaction, dice: str = "1d6"):
    match = re.match(r"(\d*)d(\d+)(?:\+(\d+))?", dice.lower().replace(" ", ""))
    if not match:
        await interaction.response.send_message("❌ Zły format. Użyj np. `2d6` lub `d20`")
        return
    count = int(match.group(1)) if match.group(1) else 1
    sides = int(match.group(2))
    bonus = int(match.group(3)) if match.group(3) else 0
    if count > 100 or sides > 1000:
        await interaction.response.send_message("❌ Za dużo kostek lub ścianek (max 100 kostek, 1000 ścianek)")
        return
    rolls = [random.randint(1, sides) for _ in range(count)]
    total = sum(rolls) + bonus
    result = f"**{total}**" + (f" ({'+'.join(map(str, rolls))}" + (f" + {bonus})" if bonus else ")") if count > 1 else "")
    await interaction.response.send_message(f"🎲 {interaction.user.mention} rzucił {dice}: {result}")


@bot.tree.command(name="coinflip", description="Rzuca monetą")
async def coinflip(interaction: discord.Interaction):
    result = random.choice(["Orzeł", "Reszka"])
    await interaction.response.send_message(f"🪙 {interaction.user.mention} dostał: **{result}**")


def banner(text, emoji=" "):
    line = "▰" * 36
    return f"```\n{line}\n{emoji}  {text}\n{line}\n```"


@bot.tree.command(name="servergenerator", description="Formatuje cały serwer od nowa")
@app_commands.default_permissions(administrator=True)
async def servergenerator(interaction: discord.Interaction):
    await interaction.response.defer(ephemeral=True)
    guild = interaction.guild

    await interaction.followup.send("⚠️ **Czy na pewno?** Za 10 sekund usunę WSZYSTKIE kanały, kategorie i role i stworzę nowy serwer od zera. Napisz `/cancel` w dowolnym kanale aby anulować.")
    await asyncio.sleep(10)

    await interaction.followup.send("🧹 **Czyszczę serwer...**")
    for channel in guild.channels:
        try:
            await channel.delete()
            await asyncio.sleep(random.uniform(1, 2.5))
        except:
            pass

    bot_roles_to_keep = set()
    if interaction.guild.me:
        for r in interaction.guild.me.roles:
            bot_roles_to_keep.add(r.id)

    for role in guild.roles:
        if role.name != "@everyone" and not role.managed and role.id not in bot_roles_to_keep:
            try:
                await role.delete()
                await asyncio.sleep(random.uniform(1, 2.5))
            except:
                pass

    await interaction.followup.send("✨ **Tworzę role...**")

    roles_data = [
        (0xE74C3C, "𝐖ł𝐚ś𝐜𝐢𝐜𝐢𝐞𝐥"),
        (0xE67E22, "𝐙𝐚𝐫𝐳ą𝐝𝐜𝐚"),
        (0x992D22, "𝐀𝐝𝐦𝐢𝐧𝐢𝐬𝐁𝐫𝐚𝐁𝐨𝐫"),
        (0x3498DB, "𝐌𝐨𝐝𝐞𝐫𝐚𝐁𝐨𝐫"),
        (0x2ECC71, "𝐏𝐨𝐦𝐨𝐜𝐧𝐢𝐤"),
        (0x1F618D, "𝐏𝐲𝐭𝐡𝐨𝐧 𝐃𝐞𝐯"),
        (0xF1C40F, "𝐉𝐒 𝐃𝐞𝐯"),
        (0x2980B9, "𝐓𝐲𝐩𝐞𝐒𝐜𝐫𝐢𝐩𝐭 𝐃𝐞𝐯"),
        (0xE67E22, "𝐉𝐚𝐯𝐚 𝐃𝐞𝐯"),
        (0x8E44AD, "𝐂++ 𝐃𝐞𝐯"),
        (0x9B59B6, "𝐂# 𝐃𝐞𝐯"),
        (0xE74C3C, "𝐑𝐮𝐬𝐭 𝐃𝐞𝐯"),
        (0x17A589, "𝐆𝐨 𝐃𝐞𝐯"),
        (0x6C3483, "𝐏𝐇𝐏 𝐃𝐞𝐯"),
        (0xCB4335, "𝐑𝐮𝐛𝐲 𝐃𝐞𝐯"),
        (0xEB984E, "𝐊𝐨𝐭𝐥𝐢𝐧 𝐃𝐞𝐯"),
        (0xE67E22, "𝐒𝐰𝐢𝐟𝐭 𝐃𝐞𝐯"),
        (0x2ECC71, "𝐑𝐞𝐚𝐜𝐭 𝐃𝐞𝐯"),
        (0x27AE60, "𝐕𝐮𝐞 𝐃𝐞𝐯"),
        (0xE74C3C, "𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐃𝐞𝐯"),
        (0x1ABC9C, "𝐍𝐞𝐱𝐭 𝐃𝐞𝐯"),
        (0x68D391, "𝐍𝐨𝐝𝐞 𝐃𝐞𝐯"),
        (0xF39C12, "𝐅𝐮𝐥𝐥𝐒𝐭𝐚𝐜𝐤"),
        (0x1E8449, "𝐃𝐣𝐚𝐧𝐠𝐨 𝐃𝐞𝐯"),
        (0x2ECC71, "𝐅𝐥𝐚𝐬𝐤 𝐃𝐞𝐯"),
        (0xE67E22, "𝐇𝐓𝐌𝐋/𝐂𝐒𝐒 𝐌𝐚𝐬𝐭𝐞𝐫"),
        (0xF1C40F, "𝐏𝐲𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫"),
        (0xF7DC6F, "𝐏𝐲𝐈𝐧𝐭𝐞𝐫𝐦𝐞𝐝𝐢𝐚𝐭𝐞"),
        (0xF9E79F, "𝐏𝐲𝐀𝐝𝐯𝐚𝐧𝐜𝐞𝐝"),
        (0x82E0AA, "𝐖𝐞𝐁 𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫"),
        (0x58D68D, "𝐖𝐞𝐁 𝐈𝐧𝐭𝐞𝐫"),
        (0x2ECC71, "𝐖𝐞𝐁 𝐀𝐝𝐯𝐚𝐧𝐜𝐞𝐝"),
        (0x85C1E9, "𝐃𝐞𝐯 𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫"),
        (0x5DADE2, "𝐃𝐞𝐯 𝐈𝐧𝐭𝐞𝐫"),
        (0x2E86C1, "𝐃𝐞𝐯 𝐄𝐱𝐩𝐞𝐫𝐭"),
        (0x6C3483, "𝐃𝐞𝐯𝐎𝐩𝐬"),
        (0x8E44AD, "𝐃𝐚𝐭𝐚𝐒𝐜𝐢𝐞𝐧𝐜𝐞"),
        (0x9B59B6, "𝐔𝐈/𝐔𝐗 𝐃𝐞𝐬𝐢𝐠𝐧"),
        (0x7D3C98, "𝐆𝐚𝐦𝐞 𝐃𝐞𝐯"),
        (0xA569BD, "𝐌𝐨𝐛𝐢𝐥𝐞 𝐃𝐞𝐯"),
        (0x4A235A, "𝐂𝐲𝐛𝐞𝐫𝐒𝐞𝐜"),
        (0x1A5276, "𝐃𝐁𝐀"),
        (0x2471A3, "𝐂𝐥𝐨𝐮𝐝 𝐄𝐧𝐠"),
        (0x5B2C6F, "𝐀𝐈/𝐌𝐋 𝐒𝐩𝐞𝐜"),
        (0x1ABC9C, "𝐃𝐞𝐬𝐢𝐠𝐧𝐞𝐫"),
        (0x17A589, "𝐂𝐫𝐞𝐚𝐭𝐨𝐫"),
        (0x148F77, "𝐁𝐞𝐭𝐚 𝐓𝐞𝐬𝐭"),
        (0xE67E22, "𝐌𝐞𝐧𝐭𝐨𝐫"),
        (0xF39C12, "𝐂𝐨𝐧𝐭𝐫𝐢𝐛𝐮𝐭𝐨𝐫"),
        (0xE74C3C, "𝐕𝐈𝐏"),
        (0xEB984E, "𝐀𝐫𝐭𝐢𝐬𝐭"),
        (0x85C1E9, "𝐌𝐮𝐳𝐲𝐤"),
        (0xF7DC6F, "𝐆𝐚𝐦𝐞𝐫"),
    ]

    all_roles = []
    for color, rn in roles_data:
        try:
            role = await guild.create_role(name=rn, color=discord.Color(color), mentionable=True, hoist=True)
            all_roles.append(role)
            await asyncio.sleep(random.uniform(1.5, 3))
        except:
            pass

    await interaction.followup.send(f"✅ {len(all_roles)} ról gotowych! 🏗️ **Tworzę kanały...**")

    admin_role = discord.utils.get(guild.roles, name="𝐀𝐝𝐦𝐢𝐧𝐢𝐬𝐭𝐫𝐚𝐭𝐨𝐫")
    mod_role = discord.utils.get(guild.roles, name="𝐌𝐨𝐝𝐞𝐫𝐚𝐭𝐨𝐫")

    priv = {guild.default_role: discord.PermissionOverwrite(read_messages=False)}
    if admin_role:
        priv[admin_role] = discord.PermissionOverwrite(read_messages=True, manage_messages=True, manage_channels=True)
    if mod_role:
        priv[mod_role] = discord.PermissionOverwrite(read_messages=True, manage_messages=True)

    structure = [
        ("📌 INFORMACJE", [
            ("📜 regulamin", banner("REGULAMIN SERWERA", "📜") + "\n📌 Przestrzegaj • Szanuj • Nie spamuj"),
            ("📢 ogloszenia", banner("OGLOSZENIA", "📢") + "\n📌 Ważne informacje i aktualizacje"),
            ("✅ role", banner("ZDOBYWAJ ROLE", "✅") + "\n📌 Kliknij reakcje aby wybrać role"),
            ("📁 pliki", banner("BAZA PROJEKTOW I PLIKOW", "📁") + "\n📌 Projekty • Skrypty • Materiały od adminów"),
            ("📖 poradniki", banner("PORADNIKI I TUTORIALE", "📖") + "\n📌 Ucz się nowych technologii • Dziel się wiedzą"),
        ]),
        ("👑 ADMINISTRACJA", [
            ("👑 panel", banner("PANEL ADMINISTRACYJNY", "👑") + "\n📌 Zarządzanie serwerem • Tylko admini"),
            ("📋 logi", banner("LOGI SERWERA", "📋") + "\n📌 Aktywność i zdarzenia"),
            ("💬 admin-chat", banner("DYSKUSJA ADMINOW", "💬") + "\n📌 Tylko dla administracji"),
            ("📁 admin-projekty", banner("PROJEKTY ADMINISTRACJI", "📁") + "\n📌 Tutaj Admini dawają swoje Projekty!"),
            ("🤖 test-bot", banner("TESTOWANIE BOTA", "🤖") + "\n📌 Testuj nowe komendy i funkcje"),
        ], priv),
        ("💬 OGYLNE", [
            ("💬 ogolna", banner("OGOLNA ROZMOWA", "💬") + "\n📌 Rozmowy na każdy temat • Poznaj społeczność"),
            ("📸 media", banner("MEDIA I ZDJECIA", "📸") + "\n📌 Memy • Screeny • Grafiki • Filmy"),
            ("🤖 bot-cmds", banner("KOMENDY DLA BOTOW", "🤖") + "\n📌 Używaj komend • Zabawa • Narzędzia"),
            ("🗳️ ankiety", banner("ANKIETY I GLOSOWANIA", "🗳️") + "\n📌 Głosowania • Opinie • Decyzje"),
            ("💡 sugestie", banner("TWOJE POMYSLY", "💡") + "\n📌 Masz pomysł na serwer? Napisz!"),
        ]),
        ("💻 PROGRAMOWANIE", [
            ("🔰 pomoc", banner("POMOC DLA POCZATKUJACYCH", "🔰") + "\n📌 Nie bój się pytać • Każdy kiedyś zaczynał"),
            ("🆘 code-help", banner("POMOC Z KODEM", "🆘") + "\n📌 Opisz problem • Pokaż błąd • Otrzymasz pomoc"),
            ("📝 code-review", banner("CODE REVIEW", "📝") + "\n📌 Wrzuć kod • Otrzymaj feedback • Rozwijaj się"),
            ("📂 projekty", banner("PROJEKTY SPOLECZNOSCI", "📂") + "\n📌 Pokaż swój projekt • Szukaj współpracy"),
            ("💡 algorytmy", banner("ALGORYTMY I STRUKTURY", "💡") + "\n📌 Dyskusja • Optymalizacja • Rozwiązania"),
        ]),
        ("🐍 PYTHON", [
            ("🐍 python-help", banner("PYTHON HELP", "🐍") + "\n📌 Biblioteki • Błędy • Zadania • Pomoc"),
            ("📦 biblioteki", banner("BIBLIOTEKI PYTHONA", "📦") + "\n📌 Polecaj • Porównuj • Dyskutuj"),
            ("🔧 python-projekty", banner("PROJEKTY W PYTHONIE", "🔧") + "\n📌 Automatyzacja • Skrypty • Aplikacje"),
            ("📊 data-science", banner("DATA SCIENCE", "📊") + "\n📌 Pandas • NumPy • ML • Analiza"),
        ]),
        ("🌐 WEB DEV", [
            ("🌐 html-css", banner("HTML & CSS", "🌐") + "\n📌 Responsywność • Frameworki • Tailwind • Bootstrap"),
            ("⚡ javascript", banner("JAVASCRIPT / TYPESCRIPT", "⚡") + "\n📌 JS • TS • Node • Frameworki"),
            ("⚛️ react-vue", banner("REACT / VUE / SVELTE", "⚛️") + "\n📌 Komponenty • Next • Nuxt • Stan"),
            ("🖥️ backend", banner("BACKEND / API", "🖥️") + "\n📌 API • Bazy • Serwery • REST • GraphQL"),
        ]),
        ("🛠 DEV TOOLS", [
            ("🐙 git-github", banner("GIT & GITHUB", "🐙") + "\n📌 CI/CD • Workflow • Pull Requesty"),
            ("🐳 docker", banner("DOCKER & DEVOPS", "🐳") + "\n📌 Kontenery • K8s • Kompozycja"),
            ("🔒 security", banner("BEZPIECZENSTWO", "🔒") + "\n📌 OWASP • Audyt • Testy • Hacking"),
            ("☁️ cloud", banner("CLOUD COMPUTING", "☁️") + "\n📌 AWS • Azure • GCP • Hosting"),
        ]),
        ("🎮 FUN", [
            ("🎵 muzyka", banner("MUZYKA", "🎵") + "\n📌 Polecaj • Playlisty • Gatunki"),
            ("🎮 gry", banner("GRY", "🎮") + "\n📌 Dyskusja • Co grasz? • Polecajki"),
            ("🤖 ai-chat", banner("AI I CHATBOTY", "🤖") + "\n📌 ChatGPT • AI Art • Prompt Engineering"),
            ("🎨 sztuka", banner("SZTUKA I DESIGN", "🎨") + "\n📌 Grafika • Pixel Art • AI Art"),
        ]),
        ("🔊 VOICE", [
            ("🔊 Ogolny", "Rozmowy na każdy temat"),
            ("🔊 Kodowanie", "Koduj razem z innymi"),
            ("🔊 Nauka", "Nauka i pomoc"),
            ("🔊 Muzyka", "Słuchaj muzyki"),
            ("🔊 Spotkania", "Meetupy i spotkania"),
        ], {"voice": True}),
    ]

    created = 0
    for item in structure:
        if len(item) == 3:
            cat_name, channels, opts = item
            if isinstance(opts, dict) and opts.get("voice"):
                is_vc = True
                perms = None
            elif isinstance(opts, dict):
                is_vc = False
                perms = opts
            else:
                is_vc = False
                perms = opts
        else:
            cat_name, channels = item
            is_vc = False
            perms = None

        try:
            category = await guild.create_category(cat_name, overwrites=perms)
        except:
            category = await guild.create_category(cat_name)
        await asyncio.sleep(random.uniform(1.5, 3))

        for ch_name, ch_topic in channels:
            try:
                if is_vc:
                    await guild.create_voice_channel(ch_name, category=category)
                else:
                    await guild.create_text_channel(ch_name, category=category, topic=ch_topic[:1024] if ch_topic else None, slowmode_delay=2 if "pomoc" in ch_name or "help" in ch_name else 0)
                created += 1
                await asyncio.sleep(random.uniform(1, 2.5))
            except:
                pass

    info_ch = discord.utils.get(guild.text_channels, name="pliki")
    if info_ch:
        emb = discord.Embed(title="📂 Projekty i Pliki", description="Witaj w bazie projektów!\nAdmini udostępniają tutaj swoje skrypty, konfiguracje i materiały.", color=discord.Color.blue())
        emb.add_field(name="📁 Projekty", value="Aplikacje i strony", inline=True)
        emb.add_field(name="📜 Skrypty", value="Automatyzacje", inline=True)
        emb.add_field(name="📖 Materiały", value="Poradniki i notatki", inline=True)
        await info_ch.send(embed=emb)

    admin_ch = discord.utils.get(guild.text_channels, name="admin-projekty")
    if admin_ch:
        emb = discord.Embed(title="👑 Projekty Administracji", description="Tutaj Admini dawają swoje Projekty!\nBackupy, konfiguracje, autorskie narzędzia.", color=discord.Color.gold())
        await admin_ch.send(embed=emb)

    embed = discord.Embed(
        title="✅ Serwer sformatowany!",
        description=f"✦ **{len(all_roles)}** ról\n✦ **{created}** kanałów\n✦ **{len(structure)}** kategorii",
        color=discord.Color.green()
    )
    embed.set_footer(text="Ustaw role i gotowe!")
    await interaction.followup.send(embed=embed)


WARNS_FILE = "warns.json"

def load_warns():
    if os.path.exists(WARNS_FILE):
        with open(WARNS_FILE) as f:
            return json.load(f)
    return {}

def save_warns(data):
    with open(WARNS_FILE, "w") as f:
        json.dump(data, f, indent=2)


@bot.tree.command(name="warn", description="Ostrzega użytkownika")
@app_commands.describe(member="Użytkownik", reason="Powód ostrzeżenia")
@app_commands.default_permissions(moderate_members=True)
async def warn(interaction: discord.Interaction, member: discord.Member, reason: str = "Nie podano powodu"):
    warns = load_warns()
    uid = str(member.id)
    if uid not in warns:
        warns[uid] = []
    warns[uid].append({"reason": reason, "by": interaction.user.id, "date": str(discord.utils.utcnow())})
    save_warns(warns)
    embed = discord.Embed(title=f"⚠️ Ostrzeżenie dla {member.display_name}", color=discord.Color.orange())
    embed.add_field(name="Powód", value=reason, inline=False)
    embed.add_field(name="Ostrzeżeń łącznie", value=len(warns[uid]), inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="warnings", description="Pokazuje ostrzeżenia użytkownika")
@app_commands.describe(member="Użytkownik")
@app_commands.default_permissions(moderate_members=True)
async def warnings(interaction: discord.Interaction, member: discord.Member):
    warns = load_warns().get(str(member.id), [])
    if not warns:
        await interaction.response.send_message(f"✅ {member.mention} nie ma ostrzeżeń")
        return
    embed = discord.Embed(title=f"⚠️ Ostrzeżenia {member.display_name}", color=discord.Color.orange())
    for i, w in enumerate(warns, 1):
        embed.add_field(name=f"#{i}", value=f"Powód: {w['reason']}\nData: {w['date']}", inline=False)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="delwarn", description="Usuwa ostrzeżenie użytkownika")
@app_commands.describe(member="Użytkownik", number="Numer ostrzeżenia do usunięcia")
@app_commands.default_permissions(moderate_members=True)
async def delwarn(interaction: discord.Interaction, member: discord.Member, number: int):
    warns = load_warns()
    uid = str(member.id)
    if uid not in warns or number < 1 or number > len(warns[uid]):
        await interaction.response.send_message("❌ Nieprawidłowy numer ostrzeżenia")
        return
    warns[uid].pop(number - 1)
    if not warns[uid]:
        del warns[uid]
    save_warns(warns)
    await interaction.response.send_message(f"✅ Usunięto ostrzeżenie #{number} u {member.mention}")


@bot.tree.command(name="poll", description="Tworzy ankietę")
@app_commands.describe(question="Pytanie", option1="Opcja 1", option2="Opcja 2", option3="Opcja 3 (opcjonalnie)", option4="Opcja 4 (opcjonalnie)")
async def poll(interaction: discord.Interaction, question: str, option1: str, option2: str, option3: str = None, option4: str = None):
    options = [o for o in [option1, option2, option3, option4] if o]
    emojis = ["1️⃣", "2️⃣", "3️⃣", "4️⃣"]
    desc = "\n".join(f"{emojis[i]} {opt}" for i, opt in enumerate(options))
    embed = discord.Embed(title=f"📊 {question}", description=desc, color=discord.Color.blue())
    embed.set_footer(text=f"Ankieta od {interaction.user.display_name}")
    await interaction.response.send_message(embed=embed)
    msg = await interaction.original_response()
    for i in range(len(options)):
        await msg.add_reaction(emojis[i])


@bot.tree.command(name="embed", description="Wysyła wiadomość embed")
@app_commands.describe(title="Tytuł", description="Opis", color="Kolor (hex np. #FF0000)")
@app_commands.default_permissions(manage_messages=True)
async def embed(interaction: discord.Interaction, title: str, description: str, color: str = "#3498DB"):
    try:
        c = discord.Color(int(color.replace("#", ""), 16))
    except:
        c = discord.Color.blue()
    emb = discord.Embed(title=title, description=description, color=c)
    await interaction.response.send_message(embed=emb)


@bot.tree.command(name="slowmode", description="Ustawia slowmode na kanale (sekundy)")
@app_commands.describe(seconds="Sekundy (0 = wyłącz)")
@app_commands.default_permissions(manage_channels=True)
async def slowmode(interaction: discord.Interaction, seconds: int):
    await interaction.channel.edit(slowmode_delay=seconds)
    if seconds > 0:
        await interaction.response.send_message(f"🐌 Ustawiono slowmode na {seconds}s")
    else:
        await interaction.response.send_message("✅ Wyłączono slowmode")


@bot.tree.command(name="nick", description="Zmienia nick użytkownika")
@app_commands.describe(member="Użytkownik", nickname="Nowy nick (wpisz 'reset' aby przywrócić)")
@app_commands.default_permissions(manage_nicknames=True)
async def nick(interaction: discord.Interaction, member: discord.Member, nickname: str = None):
    if nickname and nickname.lower() == "reset":
        nickname = None
    await member.edit(nick=nickname)
    await interaction.response.send_message(f"✅ Zmieniono nick {member.mention}" + (f" na **{nickname}**" if nickname else " (przywrócono)"))


@bot.tree.command(name="role", description="Daje lub zabiera rolę")
@app_commands.describe(action="give lub remove", member="Użytkownik", role="Rola")
@app_commands.default_permissions(manage_roles=True)
@app_commands.choices(action=[app_commands.Choice(name="give", value="give"), app_commands.Choice(name="remove", value="remove")])
async def role(interaction: discord.Interaction, action: str, member: discord.Member, role: discord.Role):
    if role >= interaction.user.top_role:
        await interaction.response.send_message("❌ Nie możesz zarządzać tą rolą")
        return
    if action == "give":
        await member.add_roles(role)
        await interaction.response.send_message(f"✅ Nadano {role.mention} dla {member.mention}")
    else:
        await member.remove_roles(role)
        await interaction.response.send_message(f"✅ Zabrano {role.mention} z {member.mention}")


@bot.tree.command(name="botinfo", description="Informacje o bocie")
async def botinfo(interaction: discord.Interaction):
    embed = discord.Embed(title="🤖 BotDC", color=discord.Color.blue())
    embed.add_field(name="Wersja", value="21", inline=True)
    embed.add_field(name="Biblioteka", value="discord.py", inline=True)
    embed.add_field(name="Prefix", value="/ (slash commands)", inline=True)
    embed.add_field(name="Serwery", value=len(bot.guilds), inline=True)
    embed.add_field(name="Użytkownicy", value=sum(g.member_count for g in bot.guilds), inline=True)
    embed.add_field(name="Autor", value="Gabeczkag", inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="membercount", description="Liczba członków na serwerze")
async def membercount(interaction: discord.Interaction):
    guild = interaction.guild
    total = guild.member_count
    humans = len([m for m in guild.members if not m.bot])
    bots = total - humans
    embed = discord.Embed(title=f"👥 Członkowie {guild.name}", color=discord.Color.blue())
    embed.add_field(name="Wszyscy", value=total, inline=True)
    embed.add_field(name="Ludzie", value=humans, inline=True)
    embed.add_field(name="Boty", value=bots, inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="announce", description="Wysyła ogłoszenie")
@app_commands.describe(title="Tytuł", message="Treść", channel="Kanał (opcjonalnie)")
@app_commands.default_permissions(administrator=True)
async def announce(interaction: discord.Interaction, title: str, message: str, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    embed = discord.Embed(title=f"📢 {title}", description=message, color=discord.Color.gold())
    embed.set_footer(text=f"Ogłoszenie od {interaction.user.display_name}")
    await channel.send(embed=embed)
    await interaction.response.send_message(f"✅ Ogłoszenie wysłane do {channel.mention}", ephemeral=True)


@bot.tree.command(name="8ball", description="Magiczna kula 8")
@app_commands.describe(question="Pytanie do kuli")
async def eightball(interaction: discord.Interaction, question: str):
    answers = [
        "Tak", "Nie", "Na pewno", "W życiu", "Zdecydowanie tak",
        "Nie licz na to", "Zapytaj później", "Nie mogę powiedzieć",
        "Tak, ale się zastanów", "Absolutnie nie", "Oczywiście!",
        "To możliwe", "Wątpię", "Moim zdaniem tak", "Nie teraz",
    ]
    embed = discord.Embed(title="🎱 Magiczna Kula 8", color=discord.Color.purple())
    embed.add_field(name="Pytanie", value=question, inline=False)
    embed.add_field(name="Odpowiedź", value=random.choice(answers), inline=False)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="rps", description="Kamień, papier, nożyce")
@app_commands.describe(choice="Twój wybór")
@app_commands.choices(choice=[
    app_commands.Choice(name="Kamień 🪨", value="kamień"),
    app_commands.Choice(name="Papier 📄", value="papier"),
    app_commands.Choice(name="Nożyce ✂️", value="nożyce"),
])
async def rps(interaction: discord.Interaction, choice: str):
    bot_choice = random.choice(["kamień", "papier", "nożyce"])
    beats = {"kamień": "nożyce", "papier": "kamień", "nożyce": "papier"}
    if choice == bot_choice:
        result = "Remis!"
    elif beats[choice] == bot_choice:
        result = "Wygrałeś!"
    else:
        result = "Przegrałeś!"
    await interaction.response.send_message(f"🪨📄✂️ **{result}**\nTy: {choice} | Bot: {bot_choice}")


JOKES = [
    "Dlaczego programiści mylą Halloween z Bożym Narodzeniem? Bo Oct 31 = Dec 25!",
    "Spotykają się dwa bity. Jeden mówi: 'Źle się czuję.' Drugi odpowiada: 'To idź do doktora, a nie do porte'a.'",
    "Jak nazywa się bardzo szybki programista? Ruski haker.",
    "Dlaczego Java nie lubi deszczu? Bo ma wyjątki.",
    "Ilu programistów potrzeba do wymiany żarówki? Żadnego, to problem hardware'owy.",
    "HTML to nie język programowania, to styl życia.",
    "NULL to mój ulubiony błąd. Znaczy, że przynajmniej coś zwróciłem.",
    "CSS to jedyny język, w którym możesz być 100% pewien, że coś jest wyśrodkowane... albo nie.",
]

@bot.tree.command(name="joke", description="Losowy żart")
async def joke(interaction: discord.Interaction):
    await interaction.response.send_message(f"😂 {random.choice(JOKES)}")


@bot.tree.command(name="say", description="Bot powtarza twój tekst")
@app_commands.describe(text="Tekst do powtórzenia")
async def say(interaction: discord.Interaction, text: str):
    await interaction.response.send_message(text)


@bot.tree.command(name="dm", description="Wysyła prywatną wiadomość użytkownikowi")
@app_commands.describe(member="Użytkownik", message="Treść wiadomości")
@app_commands.default_permissions(administrator=True)
async def dm(interaction: discord.Interaction, member: discord.Member, message: str):
    try:
        await member.send(message)
        await interaction.response.send_message(f"✅ Wysłano DM do {member.mention}", ephemeral=True)
    except:
        await interaction.response.send_message("❌ Nie udało się wysłać DM (użytkownik ma zablokowane DM)", ephemeral=True)


@bot.tree.command(name="random", description="Losowa liczba z zakresu")
@app_commands.describe(min="Minimum (domyślnie 1)", max="Maksimum (domyślnie 100)")
async def random_number(interaction: discord.Interaction, min: int = 1, max: int = 100):
    if min > max:
        await interaction.response.send_message("❌ Minimum nie może być większe niż maksimum")
        return
    num = random.randint(min, max)
    await interaction.response.send_message(f"🎲 Losowa liczba ({min}-{max}): **{num}**")


@bot.tree.command(name="choose", description="Wybierz z podanych opcji")
@app_commands.describe(options="Opcje rozdzielone przecinkami (np. pizza, sushi, kebab)")
async def choose(interaction: discord.Interaction, options: str):
    items = [o.strip() for o in options.split(",") if o.strip()]
    if len(items) < 2:
        await interaction.response.send_message("❌ Podaj co najmniej 2 opcje rozdzielone przecinkami")
        return
    choice = random.choice(items)
    await interaction.response.send_message(f"🤔 Wybieram... **{choice}**")


@bot.tree.command(name="reverse", description="Odwraca tekst")
@app_commands.describe(text="Tekst do odwrócenia")
async def reverse(interaction: discord.Interaction, text: str):
    await interaction.response.send_message(text[::-1])


@bot.tree.command(name="emojify", description="Zamienia tekst na emoji (alfabet flagowy)")
@app_commands.describe(text="Tekst do zamiany")
async def emojify(interaction: discord.Interaction, text: str):
    result = ""
    for c in text.lower():
        if "a" <= c <= "z":
            result += chr(ord(c) - ord("a") + 0x1F1E6) + " "
        elif "0" <= c <= "9":
            result += c + "\uFE0F\u20E3 "
        elif c == " ":
            result += "  "
        else:
            result += c + " "
    await interaction.response.send_message(result.strip()[:2000])


@bot.tree.command(name="clap", description="Dodaje 👏 między wyrazy")
@app_commands.describe(text="Tekst")
async def clap(interaction: discord.Interaction, text: str):
    await interaction.response.send_message(f"👏 {text.replace(' ', ' 👏 ')} 👏")


@bot.tree.command(name="mock", description="Zaśmiewaj czyjś tekst")
@app_commands.describe(text="Tekst do wyśmiania")
async def mock(interaction: discord.Interaction, text: str):
    result = "".join(c.upper() if i % 2 == 0 else c.lower() for i, c in enumerate(text))
    await interaction.response.send_message(result[:2000])


@bot.tree.command(name="vaporwave", description="Zamienia tekst na szeroki (vaporwave)")
@app_commands.describe(text="Tekst do zamiany")
async def vaporwave(interaction: discord.Interaction, text: str):
    result = ""
    for c in text:
        code = ord(c)
        if 0x21 <= code <= 0x7E:
            result += chr(code + 0xFEE0)
        else:
            result += c
    await interaction.response.send_message(result[:2000])


@bot.tree.command(name="spoiler", description="Każda litera jako spoiler")
@app_commands.describe(text="Tekst")
async def spoiler(interaction: discord.Interaction, text: str):
    result = " ".join(f"||{c}||" for c in text)
    await interaction.response.send_message(result[:2000])


@bot.tree.command(name="shrug", description="Wzrusza ramionami")
async def shrug(interaction: discord.Interaction):
    await interaction.response.send_message(r"¯\_(ツ)_/¯")


@bot.tree.command(name="tableflip", description="Przewraca stół")
async def tableflip(interaction: discord.Interaction):
    await interaction.response.send_message("(╯°□°)╯︵ ┻━┻")


@bot.tree.command(name="unflip", description="Naprawia stół")
async def unflip(interaction: discord.Interaction):
    await interaction.response.send_message("┬─┬ ノ( ゜-゜ノ)")


@bot.tree.command(name="hug", description="Przytula użytkownika")
@app_commands.describe(member="Użytkownik do przytulenia")
async def hug(interaction: discord.Interaction, member: discord.Member):
    gifs = [
        "https://media.tenor.com/G0I5Fw3dF0QAAAAC/hug-cuddle.gif",
        "https://media.tenor.com/4T9VPdN4xRkAAAAd/anime-hug.gif",
        "https://media.tenor.com/6e8YgllC7sIAAAAd/hug.gif",
    ]
    embed = discord.Embed(description=f"**{interaction.user.display_name}** przytula **{member.display_name}** 🤗", color=discord.Color.pink())
    embed.set_image(url=random.choice(gifs))
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="slap", description="Daje klapsa użytkownikowi")
@app_commands.describe(member="Użytkownik")
async def slap(interaction: discord.Interaction, member: discord.Member):
    gifs = [
        "https://media.tenor.com/j1J2LQwUs-sAAAAd/slap.gif",
        "https://media.tenor.com/Cg1M9vFhu1AAAAAd/anime-slap.gif",
    ]
    embed = discord.Embed(description=f"**{interaction.user.display_name}** daje klapsa **{member.display_name}** 👋", color=discord.Color.red())
    embed.set_image(url=random.choice(gifs))
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="nuke", description="Klonuje i usuwa kanał (czyści)")
@app_commands.default_permissions(manage_channels=True)
async def nuke(interaction: discord.Interaction):
    channel = interaction.channel
    new = await channel.clone()
    await channel.delete()
    await new.send(f"💣 Kanał wyczyszczony przez {interaction.user.mention}", delete_after=5)


@bot.tree.command(name="hide", description="Ukrywa kanał przed wszystkimi")
@app_commands.describe(channel="Kanał (opcjonalnie)")
@app_commands.default_permissions(manage_channels=True)
async def hide(interaction: discord.Interaction, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    await channel.set_permissions(interaction.guild.default_role, read_messages=False)
    await interaction.response.send_message(f"🙈 Ukryto {channel.mention}")


@bot.tree.command(name="show", description="Pokazuje kanał wszystkim")
@app_commands.describe(channel="Kanał (opcjonalnie)")
@app_commands.default_permissions(manage_channels=True)
async def show(interaction: discord.Interaction, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    await channel.set_permissions(interaction.guild.default_role, read_messages=True)
    await interaction.response.send_message(f"👀 Odkryto {channel.mention}")


@bot.tree.command(name="rename", description="Zmienia nazwę kanału")
@app_commands.describe(name="Nowa nazwa")
@app_commands.default_permissions(manage_channels=True)
async def rename(interaction: discord.Interaction, name: str):
    await interaction.channel.edit(name=name)
    await interaction.response.send_message(f"✅ Nazwa kanału zmieniona na **{name}**")


@bot.tree.command(name="roleinfo", description="Pokazuje informacje o roli")
@app_commands.describe(role="Rola")
async def roleinfo(interaction: discord.Interaction, role: discord.Role):
    embed = discord.Embed(title=f"📋 Informacje o roli", color=role.color)
    embed.add_field(name="Nazwa", value=role.name, inline=True)
    embed.add_field(name="ID", value=role.id, inline=True)
    embed.add_field(name="Kolor", value=str(role.color), inline=True)
    embed.add_field(name="Członkowie", value=len(role.members), inline=True)
    embed.add_field(name="Widoczna osobno", value="Tak" if role.hoist else "Nie", inline=True)
    embed.add_field(name="Wzmiankowalna", value="Tak" if role.mentionable else "Nie", inline=True)
    embed.add_field(name="Pozycja", value=role.position, inline=True)
    embed.add_field(name="Utworzona", value=role.created_at.strftime("%Y-%m-%d"), inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="channelinfo", description="Pokazuje informacje o kanale")
@app_commands.describe(channel="Kanał (opcjonalnie)")
async def channelinfo(interaction: discord.Interaction, channel: discord.TextChannel = None):
    channel = channel or interaction.channel
    embed = discord.Embed(title=f"ℹ️ {channel.name}", color=discord.Color.blue())
    embed.add_field(name="ID", value=channel.id, inline=True)
    embed.add_field(name="Typ", value=str(channel.type).capitalize(), inline=True)
    embed.add_field(name="Kategoria", value=channel.category.name if channel.category else "Brak", inline=True)
    embed.add_field(name="Temat", value=channel.topic or "Brak", inline=False)
    embed.add_field(name="Slowmode", value=f"{channel.slowmode_delay}s" if channel.slowmode_delay else "Wyłączony", inline=True)
    embed.add_field(name="Utworzony", value=channel.created_at.strftime("%Y-%m-%d"), inline=True)
    await interaction.response.send_message(embed=embed)


@bot.tree.command(name="servericon", description="Wyświetla ikonę serwera")
async def servericon(interaction: discord.Interaction):
    guild = interaction.guild
    if not guild.icon:
        await interaction.response.send_message("❌ Serwer nie ma ikony")
        return
    embed = discord.Embed(title=f"Ikona {guild.name}", color=discord.Color.blue())
    embed.set_image(url=guild.icon.url)
    await interaction.response.send_message(embed=embed)


bot.run(TOKEN)