Spaces:
Paused
Paused
| 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() | |
| async def ping(interaction: discord.Interaction): | |
| await interaction.response.send_message("Pong!") | |
| async def hello(interaction: discord.Interaction): | |
| await interaction.response.send_message(f"Cześć {interaction.user.mention}!") | |
| 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}") | |
| 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}") | |
| 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") | |
| 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}") | |
| async def untimeout(interaction: discord.Interaction, member: discord.Member): | |
| await member.timeout(None) | |
| await interaction.response.send_message(f"👍 Cofnięto wyciszenie {member.mention}") | |
| 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) | |
| 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}") | |
| 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}") | |
| 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) | |
| 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) | |
| 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) | |
| 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}") | |
| 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```" | |
| 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) | |
| 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) | |
| 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) | |
| 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}") | |
| 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]) | |
| 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) | |
| 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") | |
| 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)")) | |
| 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}") | |
| 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) | |
| 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) | |
| 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) | |
| 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) | |
| 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.", | |
| ] | |
| async def joke(interaction: discord.Interaction): | |
| await interaction.response.send_message(f"😂 {random.choice(JOKES)}") | |
| async def say(interaction: discord.Interaction, text: str): | |
| await interaction.response.send_message(text) | |
| 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) | |
| 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}**") | |
| 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}**") | |
| async def reverse(interaction: discord.Interaction, text: str): | |
| await interaction.response.send_message(text[::-1]) | |
| 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]) | |
| async def clap(interaction: discord.Interaction, text: str): | |
| await interaction.response.send_message(f"👏 {text.replace(' ', ' 👏 ')} 👏") | |
| 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]) | |
| 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]) | |
| async def spoiler(interaction: discord.Interaction, text: str): | |
| result = " ".join(f"||{c}||" for c in text) | |
| await interaction.response.send_message(result[:2000]) | |
| async def shrug(interaction: discord.Interaction): | |
| await interaction.response.send_message(r"¯\_(ツ)_/¯") | |
| async def tableflip(interaction: discord.Interaction): | |
| await interaction.response.send_message("(╯°□°)╯︵ ┻━┻") | |
| async def unflip(interaction: discord.Interaction): | |
| await interaction.response.send_message("┬─┬ ノ( ゜-゜ノ)") | |
| 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) | |
| 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) | |
| 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) | |
| 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}") | |
| 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}") | |
| 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}**") | |
| 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) | |
| 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) | |
| 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) | |