Delete app.py
Browse files
app.py
DELETED
|
@@ -1,229 +0,0 @@
|
|
| 1 |
-
import discord
|
| 2 |
-
from discord.ext import commands, tasks
|
| 3 |
-
import asyncio
|
| 4 |
-
from datetime import datetime, timedelta
|
| 5 |
-
from flask import Flask
|
| 6 |
-
from threading import Thread
|
| 7 |
-
import os
|
| 8 |
-
import random
|
| 9 |
-
|
| 10 |
-
app = Flask('')
|
| 11 |
-
|
| 12 |
-
@app.route('/')
|
| 13 |
-
def home():
|
| 14 |
-
return "OK"
|
| 15 |
-
|
| 16 |
-
def run():
|
| 17 |
-
app.run(host='0.0.0.0', port=7860)
|
| 18 |
-
|
| 19 |
-
def keep_alive():
|
| 20 |
-
t = Thread(target=run)
|
| 21 |
-
t.start()
|
| 22 |
-
|
| 23 |
-
intents = discord.Intents.all()
|
| 24 |
-
|
| 25 |
-
class SudoBot(commands.Bot):
|
| 26 |
-
def __init__(self):
|
| 27 |
-
super().__init__(command_prefix='$', intents=intents, help_command=None)
|
| 28 |
-
self.empty_voice_channels = {}
|
| 29 |
-
self.warnings = {}
|
| 30 |
-
self.punishments = {'kick': 3, 'ban': 5}
|
| 31 |
-
|
| 32 |
-
async def setup_hook(self):
|
| 33 |
-
self.check_voice_inactivity.start()
|
| 34 |
-
|
| 35 |
-
@tasks.loop(minutes=1)
|
| 36 |
-
async def check_voice_inactivity(self):
|
| 37 |
-
for guild in self.guilds:
|
| 38 |
-
for channel in guild.voice_channels:
|
| 39 |
-
if len(channel.name.split()) >= 2 and channel.name.split()[0].isdigit() and len(channel.name.split()[0]) == 4:
|
| 40 |
-
if len(channel.members) == 0:
|
| 41 |
-
if channel.id not in self.empty_voice_channels:
|
| 42 |
-
self.empty_voice_channels[channel.id] = datetime.utcnow()
|
| 43 |
-
else:
|
| 44 |
-
if datetime.utcnow() - self.empty_voice_channels[channel.id] > timedelta(hours=3):
|
| 45 |
-
await channel.delete()
|
| 46 |
-
del self.empty_voice_channels[channel.id]
|
| 47 |
-
else:
|
| 48 |
-
if channel.id in self.empty_voice_channels:
|
| 49 |
-
del self.empty_voice_channels[channel.id]
|
| 50 |
-
|
| 51 |
-
bot = SudoBot()
|
| 52 |
-
|
| 53 |
-
@bot.command()
|
| 54 |
-
async def help(ctx):
|
| 55 |
-
embed = discord.Embed(title="💠 System Zarządzania $udo", color=0x2b2d31)
|
| 56 |
-
embed.add_field(name="🎙️ Kanały Prywatne", value="`$stworz` - Tworzy kanał\n`$dodaj @osoba` - Nadaje dostęp\n`$usun @osoba` - Zabiera dostęp\n`$lock` - Blokuje wejście\n`$unlock` - Odblokowuje wejście\n`$limit [liczba]` - Limit osób\n`$nazwa [nowa nazwa]` - Zmienia nazwę", inline=False)
|
| 57 |
-
embed.add_field(name="🛡️ Moderacja", value="`$warn @osoba [powód]` - Ostrzeżenie\n`$unwarn @osoba` - Reset ostrzeżeń\n`$kick @osoba [powód]` - Wyrzucenie\n`$ban @osoba [powód]` - Banicja\n`$mute @osoba` - Wyciszenie\n`$unmute @osoba` - Odciszenie\n`$clear [liczba]` - Czyszczenie czatu", inline=False)
|
| 58 |
-
embed.add_field(name="⚙️ Administracja", value="`$kary [kick] [ban]` - Ustawienie limitów\n`$status` - Informacje o serwerze", inline=False)
|
| 59 |
-
embed.set_footer(text=f"Wywołane przez {ctx.author.display_name}", icon_url=ctx.author.display_avatar.url)
|
| 60 |
-
await ctx.send(embed=embed)
|
| 61 |
-
|
| 62 |
-
@bot.command()
|
| 63 |
-
async def stworz(ctx, *members: discord.Member):
|
| 64 |
-
guild = ctx.guild
|
| 65 |
-
author = ctx.author
|
| 66 |
-
channel_id = f"{random.randint(1000, 9999):04d}"
|
| 67 |
-
channel_name = f"{channel_id} {author.display_name}"
|
| 68 |
-
|
| 69 |
-
overwrites = {
|
| 70 |
-
guild.default_role: discord.PermissionOverwrite(connect=False, view_channel=True),
|
| 71 |
-
author: discord.PermissionOverwrite(connect=True, manage_channels=True, view_channel=True, mute_members=True, deafen_members=True, move_members=True),
|
| 72 |
-
guild.me: discord.PermissionOverwrite(connect=True, manage_channels=True, view_channel=True)
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
for member in members:
|
| 76 |
-
overwrites[member] = discord.PermissionOverwrite(connect=True, view_channel=True)
|
| 77 |
-
|
| 78 |
-
channel = await guild.create_voice_channel(name=channel_name, overwrites=overwrites)
|
| 79 |
-
|
| 80 |
-
embed = discord.Embed(title="✅ Twój prywatny kanał jest gotowy", color=0x57F287)
|
| 81 |
-
embed.add_field(name="Kanał", value=channel.mention)
|
| 82 |
-
embed.add_field(name="Zarządzanie", value="Użyj `$help` na tym czacie, aby poznać komendy kanału głosowego.", inline=False)
|
| 83 |
-
await ctx.send(embed=embed)
|
| 84 |
-
|
| 85 |
-
@bot.command()
|
| 86 |
-
async def dodaj(ctx, *members: discord.Member):
|
| 87 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 88 |
-
return await ctx.send(embed=discord.Embed(description="❌ Nie jesteś na swoim kanale głosowym.", color=0xED4245))
|
| 89 |
-
|
| 90 |
-
channel = ctx.author.voice.channel
|
| 91 |
-
for member in members:
|
| 92 |
-
await channel.set_permissions(member, connect=True, view_channel=True)
|
| 93 |
-
await ctx.send(embed=discord.Embed(description=f"✅ Dodano {len(members)} osób do kanału.", color=0x57F287))
|
| 94 |
-
|
| 95 |
-
@bot.command()
|
| 96 |
-
async def usun(ctx, *members: discord.Member):
|
| 97 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 98 |
-
return await ctx.send(embed=discord.Embed(description="❌ Nie jesteś na swoim kanale głosowym.", color=0xED4245))
|
| 99 |
-
|
| 100 |
-
channel = ctx.author.voice.channel
|
| 101 |
-
for member in members:
|
| 102 |
-
await channel.set_permissions(member, overwrite=None)
|
| 103 |
-
if member.voice and member.voice.channel == channel:
|
| 104 |
-
await member.move_to(None)
|
| 105 |
-
await ctx.send(embed=discord.Embed(description=f"🚪 Usunięto i wyrzucono {len(members)} osób.", color=0xED4245))
|
| 106 |
-
|
| 107 |
-
@bot.command()
|
| 108 |
-
async def lock(ctx):
|
| 109 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 110 |
-
return
|
| 111 |
-
await ctx.author.voice.channel.set_permissions(ctx.guild.default_role, connect=False, view_channel=True)
|
| 112 |
-
await ctx.send(embed=discord.Embed(description="🔒 Kanał został zablokowany (nikt obcy nie wejdzie).", color=0xFEE75C))
|
| 113 |
-
|
| 114 |
-
@bot.command()
|
| 115 |
-
async def unlock(ctx):
|
| 116 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 117 |
-
return
|
| 118 |
-
await ctx.author.voice.channel.set_permissions(ctx.guild.default_role, connect=True, view_channel=True)
|
| 119 |
-
await ctx.send(embed=discord.Embed(description="🔓 Kanał został odblokowany (każdy może wejść).", color=0x57F287))
|
| 120 |
-
|
| 121 |
-
@bot.command()
|
| 122 |
-
async def limit(ctx, user_limit: int):
|
| 123 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 124 |
-
return
|
| 125 |
-
await ctx.author.voice.channel.edit(user_limit=user_limit)
|
| 126 |
-
await ctx.send(embed=discord.Embed(description=f"👥 Ustawiono limit miejsc na: {user_limit}.", color=0x5865F2))
|
| 127 |
-
|
| 128 |
-
@bot.command()
|
| 129 |
-
async def nazwa(ctx, *, new_name: str):
|
| 130 |
-
if not ctx.author.voice or not ctx.author.voice.channel or not ctx.author.voice.channel.permissions_for(ctx.author).manage_channels:
|
| 131 |
-
return
|
| 132 |
-
channel = ctx.author.voice.channel
|
| 133 |
-
channel_id = channel.name.split()[0] if len(channel.name.split()) >= 2 and channel.name.split()[0].isdigit() else f"{random.randint(1000, 9999):04d}"
|
| 134 |
-
await channel.edit(name=f"{channel_id} {new_name}")
|
| 135 |
-
await ctx.send(embed=discord.Embed(description=f"✏️ Zmieniono nazwę na: {new_name}.", color=0x5865F2))
|
| 136 |
-
|
| 137 |
-
@bot.command()
|
| 138 |
-
@commands.has_permissions(manage_messages=True)
|
| 139 |
-
async def clear(ctx, amount: int):
|
| 140 |
-
await ctx.channel.purge(limit=amount + 1)
|
| 141 |
-
msg = await ctx.send(embed=discord.Embed(description=f"🧹 Usunięto {amount} wiadomości.", color=0x57F287))
|
| 142 |
-
await asyncio.sleep(3)
|
| 143 |
-
await msg.delete()
|
| 144 |
-
|
| 145 |
-
@bot.command()
|
| 146 |
-
@commands.has_permissions(manage_roles=True)
|
| 147 |
-
async def mute(ctx, member: discord.Member):
|
| 148 |
-
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
| 149 |
-
if not role:
|
| 150 |
-
role = await ctx.guild.create_role(name="Muted")
|
| 151 |
-
for channel in ctx.guild.channels:
|
| 152 |
-
await channel.set_permissions(role, send_messages=False, speak=False)
|
| 153 |
-
await member.add_roles(role)
|
| 154 |
-
await ctx.send(embed=discord.Embed(description=f"🔇 Wyciszono {member.mention}.", color=0xED4245))
|
| 155 |
-
|
| 156 |
-
@bot.command()
|
| 157 |
-
@commands.has_permissions(manage_roles=True)
|
| 158 |
-
async def unmute(ctx, member: discord.Member):
|
| 159 |
-
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
| 160 |
-
if role in member.roles:
|
| 161 |
-
await member.remove_roles(role)
|
| 162 |
-
await ctx.send(embed=discord.Embed(description=f"🔊 Odciszono {member.mention}.", color=0x57F287))
|
| 163 |
-
|
| 164 |
-
@bot.command()
|
| 165 |
-
@commands.has_permissions(kick_members=True)
|
| 166 |
-
async def warn(ctx, member: discord.Member, *, reason="Brak"):
|
| 167 |
-
user_id = str(member.id)
|
| 168 |
-
bot.warnings[user_id] = bot.warnings.get(user_id, 0) + 1
|
| 169 |
-
current = bot.warnings[user_id]
|
| 170 |
-
|
| 171 |
-
embed = discord.Embed(title="⚠️ Ostrzeżenie", color=0xFEE75C)
|
| 172 |
-
embed.add_field(name="Użytkownik", value=member.mention)
|
| 173 |
-
embed.add_field(name="Powód", value=reason)
|
| 174 |
-
embed.add_field(name="Licznik", value=f"{current}")
|
| 175 |
-
await ctx.send(embed=embed)
|
| 176 |
-
|
| 177 |
-
if current >= bot.punishments['ban']:
|
| 178 |
-
await member.ban(reason="Limit ostrzeżeń")
|
| 179 |
-
await ctx.send(embed=discord.Embed(description=f"🔨 {member.mention} zbanowany (limit ostrzeżeń).", color=0xED4245))
|
| 180 |
-
elif current >= bot.punishments['kick']:
|
| 181 |
-
await member.kick(reason="Limit ostrzeżeń")
|
| 182 |
-
await ctx.send(embed=discord.Embed(description=f"👢 {member.mention} wyrzucony (limit ostrzeżeń).", color=0xED4245))
|
| 183 |
-
|
| 184 |
-
@bot.command()
|
| 185 |
-
@commands.has_permissions(kick_members=True)
|
| 186 |
-
async def unwarn(ctx, member: discord.Member):
|
| 187 |
-
user_id = str(member.id)
|
| 188 |
-
if user_id in bot.warnings:
|
| 189 |
-
bot.warnings[user_id] = 0
|
| 190 |
-
await ctx.send(embed=discord.Embed(description=f"✅ Zresetowano ostrzeżenia {member.mention}.", color=0x57F287))
|
| 191 |
-
|
| 192 |
-
@bot.command()
|
| 193 |
-
@commands.has_permissions(administrator=True)
|
| 194 |
-
async def kary(ctx, kicks: int, bans: int):
|
| 195 |
-
bot.punishments['kick'] = kicks
|
| 196 |
-
bot.punishments['ban'] = bans
|
| 197 |
-
await ctx.send(embed=discord.Embed(description=f"⚙️ Nowe limity: Kick ({kicks}), Ban ({bans}).", color=0x5865F2))
|
| 198 |
-
|
| 199 |
-
@bot.command()
|
| 200 |
-
@commands.has_permissions(kick_members=True)
|
| 201 |
-
async def kick(ctx, member: discord.Member, *, reason="Brak"):
|
| 202 |
-
await member.kick(reason=reason)
|
| 203 |
-
await ctx.send(embed=discord.Embed(description=f"👢 Wyrzucono {member.mention} ({reason}).", color=0xED4245))
|
| 204 |
-
|
| 205 |
-
@bot.command()
|
| 206 |
-
@commands.has_permissions(ban_members=True)
|
| 207 |
-
async def ban(ctx, member: discord.Member, *, reason="Brak"):
|
| 208 |
-
await member.ban(reason=reason)
|
| 209 |
-
await ctx.send(embed=discord.Embed(description=f"🔨 Zbanowano {member.mention} ({reason}).", color=0xED4245))
|
| 210 |
-
|
| 211 |
-
@bot.command()
|
| 212 |
-
async def status(ctx):
|
| 213 |
-
embed = discord.Embed(title="📊 Status Serwera", color=0x2b2d31)
|
| 214 |
-
embed.add_field(name="Użytkownicy", value=ctx.guild.member_count)
|
| 215 |
-
embed.add_field(name="Kanały głosowe bota", value=len([c for c in ctx.guild.voice_channels if len(c.name.split()) >= 2 and c.name.split()[0].isdigit()]))
|
| 216 |
-
embed.add_field(name="Opóźnienie (Ping)", value=f"{round(bot.latency * 1000)}ms")
|
| 217 |
-
await ctx.send(embed=embed)
|
| 218 |
-
|
| 219 |
-
@bot.event
|
| 220 |
-
async def on_command_error(ctx, error):
|
| 221 |
-
if isinstance(error, commands.MissingPermissions):
|
| 222 |
-
await ctx.send(embed=discord.Embed(description="❌ Nie masz uprawnień do tej komendy.", color=0xED4245))
|
| 223 |
-
elif isinstance(error, commands.MissingRequiredArgument):
|
| 224 |
-
await ctx.send(embed=discord.Embed(description="❌ Brakuje argumentu. Sprawdź `$help`.", color=0xED4245))
|
| 225 |
-
|
| 226 |
-
keep_alive()
|
| 227 |
-
# TUTAJ WPISZ KLUCZ API
|
| 228 |
-
TOKEN = os.getenv('DISCORD_TOKEN')
|
| 229 |
-
bot.run(TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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