Spaces:
Paused
Paused
Moderation commands + version 2
Browse files- au.version +1 -1
- bot.py +84 -1
au.version
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
2
|
bot.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
load_dotenv()
|
|
@@ -9,6 +11,7 @@ TOKEN = os.getenv("DISCORD_TOKEN")
|
|
| 9 |
|
| 10 |
intents = discord.Intents.default()
|
| 11 |
intents.message_content = True
|
|
|
|
| 12 |
|
| 13 |
bot = commands.Bot(command_prefix="!", intents=intents)
|
| 14 |
|
|
@@ -28,10 +31,90 @@ async def hello(ctx):
|
|
| 28 |
await ctx.send(f"Cześć {ctx.author.mention}!")
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
async def start_bot():
|
| 32 |
async with bot:
|
| 33 |
await bot.start(TOKEN)
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
-
import asyncio
|
| 37 |
asyncio.run(start_bot())
|
|
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
| 3 |
import os
|
| 4 |
+
import asyncio
|
| 5 |
+
from datetime import timedelta
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
|
| 8 |
load_dotenv()
|
|
|
|
| 11 |
|
| 12 |
intents = discord.Intents.default()
|
| 13 |
intents.message_content = True
|
| 14 |
+
intents.members = True
|
| 15 |
|
| 16 |
bot = commands.Bot(command_prefix="!", intents=intents)
|
| 17 |
|
|
|
|
| 31 |
await ctx.send(f"Cześć {ctx.author.mention}!")
|
| 32 |
|
| 33 |
|
| 34 |
+
@bot.command()
|
| 35 |
+
@commands.has_permissions(kick_members=True)
|
| 36 |
+
async def kick(ctx, member: discord.Member, *, reason="Nie podano powodu"):
|
| 37 |
+
await member.kick(reason=reason)
|
| 38 |
+
await ctx.send(f"👍 Wyrzucono {member.mention}. Powód: {reason}")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
@bot.command()
|
| 42 |
+
@commands.has_permissions(ban_members=True)
|
| 43 |
+
async def ban(ctx, member: discord.Member, *, reason="Nie podano powodu"):
|
| 44 |
+
await member.ban(reason=reason)
|
| 45 |
+
await ctx.send(f"👍 Zbanowano {member.mention}. Powód: {reason}")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
@bot.command()
|
| 49 |
+
@commands.has_permissions(ban_members=True)
|
| 50 |
+
async def unban(ctx, *, member):
|
| 51 |
+
banned = [u async for u in ctx.guild.bans()]
|
| 52 |
+
name, discrim = member.split("#")
|
| 53 |
+
user = next((u for u in banned if u.user.name == name and u.user.discriminator == discrim), None)
|
| 54 |
+
if user:
|
| 55 |
+
await ctx.guild.unban(user.user)
|
| 56 |
+
await ctx.send(f"👍 Odbanowano {user.user}")
|
| 57 |
+
else:
|
| 58 |
+
await ctx.send("❌ Nie znaleziono użytkownika")
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
@bot.command()
|
| 62 |
+
@commands.has_permissions(moderate_members=True)
|
| 63 |
+
async def timeout(ctx, member: discord.Member, minutes: int, *, reason="Nie podano powodu"):
|
| 64 |
+
await member.timeout(discord.utils.utcnow() + timedelta(minutes=minutes), reason=reason)
|
| 65 |
+
await ctx.send(f"👍 Wyciszono {member.mention} na {minutes} min. Powód: {reason}")
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@bot.command()
|
| 69 |
+
@commands.has_permissions(moderate_members=True)
|
| 70 |
+
async def untimeout(ctx, member: discord.Member):
|
| 71 |
+
await member.timeout(None)
|
| 72 |
+
await ctx.send(f"👍 Cofnięto wyciszenie {member.mention}")
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@bot.command()
|
| 76 |
+
@commands.has_permissions(manage_messages=True)
|
| 77 |
+
async def clear(ctx, amount: int):
|
| 78 |
+
await ctx.channel.purge(limit=amount + 1)
|
| 79 |
+
await ctx.send(f"👍 Usunięto {amount} wiadomości", delete_after=5)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
@bot.command()
|
| 83 |
+
@commands.has_permissions(manage_channels=True)
|
| 84 |
+
async def lock(ctx, channel: discord.TextChannel = None):
|
| 85 |
+
channel = channel or ctx.channel
|
| 86 |
+
await channel.set_permissions(ctx.guild.default_role, send_messages=False)
|
| 87 |
+
await ctx.send(f"🔒 Zablokowano {channel.mention}")
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
@bot.command()
|
| 91 |
+
@commands.has_permissions(manage_channels=True)
|
| 92 |
+
async def unlock(ctx, channel: discord.TextChannel = None):
|
| 93 |
+
channel = channel or ctx.channel
|
| 94 |
+
await channel.set_permissions(ctx.guild.default_role, send_messages=True)
|
| 95 |
+
await ctx.send(f"🔓 Odblokowano {channel.mention}")
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
@clear.error
|
| 99 |
+
@kick.error
|
| 100 |
+
@ban.error
|
| 101 |
+
@unban.error
|
| 102 |
+
@timeout.error
|
| 103 |
+
@untimeout.error
|
| 104 |
+
@lock.error
|
| 105 |
+
@unlock.error
|
| 106 |
+
async def mod_error(ctx, error):
|
| 107 |
+
if isinstance(error, commands.MissingPermissions):
|
| 108 |
+
await ctx.send("❌ Nie masz uprawnień do tej komendy")
|
| 109 |
+
elif isinstance(error, commands.BadArgument):
|
| 110 |
+
await ctx.send("❌ Nieprawidłowy argument. Sprawdź składnię")
|
| 111 |
+
else:
|
| 112 |
+
await ctx.send(f"❌ Błąd: {error}")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
async def start_bot():
|
| 116 |
async with bot:
|
| 117 |
await bot.start(TOKEN)
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
|
|
|
| 120 |
asyncio.run(start_bot())
|