Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bddaa11523 | ||
|
|
f309a8c05f | ||
|
|
dd08709c56 | ||
|
|
3163fcb184 | ||
|
|
bbd87f524d | ||
|
|
887fdbf25c | ||
|
|
d53fd4790b | ||
|
|
704d590a42 | ||
|
|
928b1f3893 | ||
|
|
22357ee7b2 | ||
|
|
695ea56442 | ||
|
|
3ff4f0bc9b | ||
|
|
bdf5088650 | ||
|
|
e23950b93c | ||
|
|
150c36da28 | ||
|
|
ec2bbf406c | ||
|
|
b92557b176 | ||
|
|
b3c7b34863 | ||
|
|
4d34daa1e7 | ||
|
|
d564756511 | ||
|
|
7882ba4915 |
No files matched your search
+25
-1
@@ -1,3 +1,27 @@
|
|||||||
|
DEV_MODE=False
|
||||||
|
|
||||||
DISCORD_TOKEN=""
|
DISCORD_TOKEN=""
|
||||||
|
|
||||||
CREATE_CHANNEL_ID=
|
GUILD_ID=
|
||||||
|
|
||||||
|
JOIN_LEAVE_CHANNEL_ID=
|
||||||
|
|
||||||
|
CREATE_TICKET_CHANNEL_ID=
|
||||||
|
TICKET_LOGS_CHANNEL_ID=
|
||||||
|
TICKET_UNCLAIMED_CATEGORY_ID=
|
||||||
|
TICKET_CLAIMED_CATEGORY_ID=
|
||||||
|
TICKET_CLOSED_CATEGORY_ID=
|
||||||
|
|
||||||
|
TICKET_ADMIN_ROLE_IDS=
|
||||||
|
TICKET_ADMIN_PING_ROLE_ID=
|
||||||
|
|
||||||
|
CREATE_MEETUP_CHANNEL_ID=
|
||||||
|
DE_MEETUP_CHANNEL_ID=
|
||||||
|
AT_MEETUP_CHANNEL_ID=
|
||||||
|
CH_MEETUP_CHANNEL_ID=
|
||||||
|
US_MEETUP_CHANNEL_ID=
|
||||||
|
UK_MEETUP_CHANNEL_ID=
|
||||||
|
|
||||||
|
COUNTING_CHANNEL_ID=
|
||||||
|
|
||||||
|
HONEYPOT_CHANNEL_ID=
|
||||||
@@ -3,3 +3,5 @@ __pycache__/
|
|||||||
*$py.class
|
*$py.class
|
||||||
|
|
||||||
*.env
|
*.env
|
||||||
|
*.db
|
||||||
|
SQLite/
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.13-slim
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
WORKDIR /bot
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["python", "main.py"]
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import os
|
||||||
|
import aiosqlite
|
||||||
|
|
||||||
|
DB_PATH = "SQLite/FemBot.db"
|
||||||
|
|
||||||
|
class Database:
|
||||||
|
def __init__(self):
|
||||||
|
self.conn = None
|
||||||
|
self._lock = None
|
||||||
|
|
||||||
|
async def _ensure_schema(self):
|
||||||
|
await self.conn.executescript("""
|
||||||
|
CREATE TABLE IF NOT EXISTS test (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
message TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS tickets (
|
||||||
|
ticket_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
ticket_channel_id TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
user_id TEXT NOT NULL,
|
||||||
|
language TEXT NOT NULL,
|
||||||
|
reason TEXT NOT NULL,
|
||||||
|
|
||||||
|
opened_at TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
closed_at TEXT DEFAULT NULL,
|
||||||
|
is_open INTEGER DEFAULT 1 CHECK (is_open IN (0, 1)),
|
||||||
|
|
||||||
|
claimed_user_id TEXT DEFAULT NULL,
|
||||||
|
claimed_at TEXT DEFAULT NULL,
|
||||||
|
is_claimed INTEGER DEFAULT 0 CHECK (is_claimed IN (0, 1))
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS count (
|
||||||
|
count INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id TEXT NOT NULL
|
||||||
|
);
|
||||||
|
""")
|
||||||
|
|
||||||
|
await self.conn.commit()
|
||||||
|
|
||||||
|
async def connect(self):
|
||||||
|
if self._lock is None:
|
||||||
|
import asyncio
|
||||||
|
self._lock = asyncio.Lock()
|
||||||
|
|
||||||
|
async with self._lock:
|
||||||
|
if self.conn is not None:
|
||||||
|
try:
|
||||||
|
await self.conn.execute("SELECT 1")
|
||||||
|
return self.conn
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
await self.conn.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self.conn = None
|
||||||
|
|
||||||
|
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
|
||||||
|
|
||||||
|
db_existed = os.path.exists(DB_PATH)
|
||||||
|
if db_existed:
|
||||||
|
print(f"Using existing database file at {DB_PATH}")
|
||||||
|
else:
|
||||||
|
print(f"Database file not found at {DB_PATH}, creating a new one...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.conn = await aiosqlite.connect(DB_PATH)
|
||||||
|
except aiosqlite.Error as e:
|
||||||
|
print(f"Failed to open database at {DB_PATH}: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
if not db_existed and not os.path.exists(DB_PATH):
|
||||||
|
print(f"Warning: database file was expected at {DB_PATH} but still missing after connect.")
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self._ensure_schema()
|
||||||
|
print("Table check/creation completed successfully.")
|
||||||
|
except aiosqlite.Error as e:
|
||||||
|
print(f"Failed to check/creation table: {e}")
|
||||||
|
|
||||||
|
return self.conn
|
||||||
|
|
||||||
|
async def get_conn(self):
|
||||||
|
if self.conn is not None:
|
||||||
|
try:
|
||||||
|
await self.conn.execute("SELECT 1")
|
||||||
|
return self.conn
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
await self.conn.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self.conn = None
|
||||||
|
await self.connect()
|
||||||
|
return self.conn
|
||||||
|
|
||||||
|
async def close(self):
|
||||||
|
if self.conn:
|
||||||
|
try:
|
||||||
|
await self.conn.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self.conn = None
|
||||||
@@ -11,7 +11,6 @@ from datetime import datetime
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
CREATE_CHANNEL_ID = os.getenv('CREATE_CHANNEL_ID')
|
|
||||||
|
|
||||||
class ConfirmInteractiveMenu(discord.ui.View):
|
class ConfirmInteractiveMenu(discord.ui.View):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -53,6 +52,11 @@ def get_state_from_postal_code(country_code: str, postal_code: str) -> str:
|
|||||||
"country": country_code
|
"country": country_code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = {
|
||||||
|
"state": "Error: State not found :c",
|
||||||
|
"settlement": "Error: settlement not found :c"
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
location = geolocator.geocode(query, addressdetails=True, timeout=10)
|
location = geolocator.geocode(query, addressdetails=True, timeout=10)
|
||||||
|
|
||||||
@@ -62,9 +66,16 @@ def get_state_from_postal_code(country_code: str, postal_code: str) -> str:
|
|||||||
state_keys = ["state", "province", "state_district", "region"]
|
state_keys = ["state", "province", "state_district", "region"]
|
||||||
for key in state_keys:
|
for key in state_keys:
|
||||||
if key in address:
|
if key in address:
|
||||||
return address[key]
|
result["state"] = address[key]
|
||||||
|
break
|
||||||
|
|
||||||
return "Error: State not found :c"
|
settlement_keys = ["village", "hamlet", "suburb", "town", "city", "municipality"]
|
||||||
|
for key in settlement_keys:
|
||||||
|
if key in address:
|
||||||
|
result["settlement"] = address[key]
|
||||||
|
break
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
except GeocoderTimedOut:
|
except GeocoderTimedOut:
|
||||||
return "Error: Request timed out :c"
|
return "Error: Request timed out :c"
|
||||||
@@ -161,17 +172,23 @@ class CreateMeetupForm(discord.ui.Modal, title="Create a local meetup"):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.state = get_state_from_postal_code(self.chosen_country, self.form_postal_code.value)
|
result = get_state_from_postal_code(self.chosen_country, self.form_postal_code.value)
|
||||||
|
self.state = result["state"]
|
||||||
|
self.settlement = result["settlement"]
|
||||||
|
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
content=(
|
content=(
|
||||||
"## Event Register Preview\n"
|
"## Event Register Preview\n"
|
||||||
f"**Country:** {self.chosen_country}\n"
|
f"**Country:** {self.chosen_country}\n"
|
||||||
f"**Postal Code:** {self.form_postal_code.value}\n"
|
|
||||||
f"**State:** {self.state}\n"
|
f"**State:** {self.state}\n"
|
||||||
|
|
||||||
|
f"**City:** {self.form_postal_code.value} {self.settlement}\n"
|
||||||
|
"> \n"
|
||||||
f"**Date:** {valid_date}\n"
|
f"**Date:** {valid_date}\n"
|
||||||
f"**Time:** {formatted_start} - {formatted_end}\n"
|
f"**Time:** {formatted_start} - {formatted_end}\n"
|
||||||
|
f"**Organizer:** {interaction.user.mention}\n"
|
||||||
f"**Location:** {self.form_location.value}\n"
|
f"**Location:** {self.form_location.value}\n"
|
||||||
|
"-# bla bla bla bla"
|
||||||
),
|
),
|
||||||
ephemeral=True, view=ConfirmInteractiveMenu()
|
ephemeral=True, view=ConfirmInteractiveMenu()
|
||||||
)
|
)
|
||||||
@@ -205,7 +222,7 @@ class CountryDropdownView(discord.ui.View):
|
|||||||
|
|
||||||
class MainInteractiveMenu(discord.ui.View):
|
class MainInteractiveMenu(discord.ui.View):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__(timeout=None)
|
||||||
|
|
||||||
@discord.ui.button(label="Register a Meetup", style=discord.ButtonStyle.success)
|
@discord.ui.button(label="Register a Meetup", style=discord.ButtonStyle.success)
|
||||||
async def primary_button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def primary_button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
@@ -229,7 +246,7 @@ class CreateMeetup(commands.Cog):
|
|||||||
async def startup(self):
|
async def startup(self):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
channel = await self.bot.fetch_channel(CREATE_CHANNEL_ID)
|
channel = await self.bot.fetch_channel(os.getenv("CREATE_MEETUP_CHANNEL_ID"))
|
||||||
|
|
||||||
await channel.purge(limit=None, bulk=True)
|
await channel.purge(limit=None, bulk=True)
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from discord import app_commands
|
||||||
|
|
||||||
|
class DBTest(commands.Cog):
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@app_commands.command(name="test_db", description="Tests the database connection")
|
||||||
|
async def test_db(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer(ephemeral=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
db = self.bot.database.conn
|
||||||
|
|
||||||
|
async with db.execute("SELECT 1;") as cursor:
|
||||||
|
result = await cursor.fetchone()
|
||||||
|
|
||||||
|
if result:
|
||||||
|
await interaction.followup.send("Database connection successful!")
|
||||||
|
else:
|
||||||
|
await interaction.followup.send("Database responded, but returned no data.")
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
await interaction.followup.send(f"Database connection failed: {e}")
|
||||||
|
|
||||||
|
@app_commands.command(name="test_db_add", description="Add a string to the Database")
|
||||||
|
@app_commands.describe(message="a message")
|
||||||
|
async def test_db(self, interaction: discord.Interaction, message: str):
|
||||||
|
await interaction.response.defer(ephemeral=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
db = self.bot.database.conn
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
"INSERT INTO test (message) VALUES (?)",
|
||||||
|
(message,)
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
await interaction.followup.send("Database INSERT was successful!")
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
await interaction.followup.send(f"Database INSERT failed: {e}")
|
||||||
|
|
||||||
|
async def setup(bot: commands.Bot):
|
||||||
|
await bot.add_cog(DBTest(bot))
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
services:
|
||||||
|
discord-bot-fembot:
|
||||||
|
build: .
|
||||||
|
container_name: discord_bot_fembot
|
||||||
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- .:/bot
|
||||||
|
- fembot_db:/bot/SQLite
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
fembot_db:
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from simpleeval import simple_eval, InvalidExpression
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
COUNTING_CHANNEL_ID = int(os.getenv("COUNTING_CHANNEL_ID"))
|
||||||
|
|
||||||
|
_MATH_CHARS = re.compile(r"[^\d\+\-\*\/\(\)\^\%\.\s]")
|
||||||
|
|
||||||
|
def solve_string(content: str) -> int | None:
|
||||||
|
expr = _MATH_CHARS.sub("", content)
|
||||||
|
expr = expr.strip()
|
||||||
|
|
||||||
|
if not expr or not any(ch.isdigit() for ch in expr):
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
value = simple_eval(expr)
|
||||||
|
except (InvalidExpression, ZeroDivisionError, ValueError, SyntaxError, TypeError, KeyError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
if isinstance(value, bool):
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
return int(value)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
class Counting(commands.Cog):
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_message(self, message: discord.Message):
|
||||||
|
if not message or not message.author or message.webhook_id is not None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if message.author.bot:
|
||||||
|
return
|
||||||
|
|
||||||
|
if message.channel.id != COUNTING_CHANNEL_ID:
|
||||||
|
return
|
||||||
|
|
||||||
|
db = await self.bot.database.get_conn()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with db.execute(
|
||||||
|
"SELECT count, user_id FROM count ORDER BY count DESC LIMIT 1"
|
||||||
|
) as cursor:
|
||||||
|
result = await cursor.fetchone()
|
||||||
|
|
||||||
|
if result is None:
|
||||||
|
expected = 1
|
||||||
|
previous_user_id = None
|
||||||
|
else:
|
||||||
|
expected = result[0] + 1
|
||||||
|
previous_user_id = result[1]
|
||||||
|
|
||||||
|
parsed = solve_string(message.content)
|
||||||
|
is_correct = (
|
||||||
|
parsed is not None
|
||||||
|
and parsed == expected
|
||||||
|
and previous_user_id != str(message.author.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not is_correct:
|
||||||
|
try:
|
||||||
|
await message.delete()
|
||||||
|
except discord.NotFound:
|
||||||
|
pass
|
||||||
|
return
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
"INSERT INTO count (user_id) VALUES (?)",
|
||||||
|
(str(message.author.id),)
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
await message.add_reaction("✅")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Database error: {e}")
|
||||||
|
try:
|
||||||
|
await message.delete()
|
||||||
|
except discord.NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot: commands.Bot):
|
||||||
|
await bot.add_cog(Counting(bot))
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
import os
|
||||||
|
import datetime
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands, tasks
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
HONEYPOT_CHANNEL_ID = os.getenv("HONEYPOT_CHANNEL_ID", "").strip()
|
||||||
|
PURGE_MINUTES = 15
|
||||||
|
|
||||||
|
|
||||||
|
def parse_channel_id(raw_value: str) -> int | None:
|
||||||
|
if not raw_value:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
return int(raw_value)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class Honeypot(commands.Cog):
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.channel_id = parse_channel_id(HONEYPOT_CHANNEL_ID)
|
||||||
|
|
||||||
|
async def cog_load(self):
|
||||||
|
if self.channel_id is None:
|
||||||
|
print("Honeypot disabled: HONEYPOT_CHANNEL_ID is missing or invalid.")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"Honeypot watching channel ID {self.channel_id}")
|
||||||
|
self.startup.start()
|
||||||
|
|
||||||
|
def cog_unload(self):
|
||||||
|
self.startup.cancel()
|
||||||
|
|
||||||
|
@tasks.loop(count=1)
|
||||||
|
async def startup(self):
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
|
channel = self.bot.get_channel(self.channel_id)
|
||||||
|
if channel is None:
|
||||||
|
try:
|
||||||
|
channel = await self.bot.fetch_channel(self.channel_id)
|
||||||
|
except discord.HTTPException as error:
|
||||||
|
print(f"Honeypot: could not fetch channel {self.channel_id}: {error}")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not isinstance(channel, discord.TextChannel):
|
||||||
|
print(f"Honeypot: channel {self.channel_id} is not a text channel.")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await channel.purge(limit=None, reason="Honeypot startup cleanup")
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Nicht hier schreiben / Do not post here",
|
||||||
|
description=(
|
||||||
|
"Dieser Kanal ist ein honeypot. Jede Nachricht wird gelöscht und "
|
||||||
|
"das Mitglied wird gekickt.\n\n"
|
||||||
|
"This channel is a honeypot. Any message posted here will be "
|
||||||
|
"deleted and the member will be kicked.\n\n"
|
||||||
|
"**Nicht in diesen Kanal schreiben. / Do not write in this channel.**"
|
||||||
|
),
|
||||||
|
color=discord.Color.red(),
|
||||||
|
)
|
||||||
|
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
except discord.HTTPException as error:
|
||||||
|
print(f"Honeypot: failed to prepare channel {self.channel_id}: {error}")
|
||||||
|
|
||||||
|
async def purge_recent_user_messages(self, guild: discord.Guild, user_id: int):
|
||||||
|
cutoff = discord.utils.utcnow() - datetime.timedelta(minutes=PURGE_MINUTES)
|
||||||
|
channels = [
|
||||||
|
*guild.text_channels,
|
||||||
|
*guild.voice_channels,
|
||||||
|
*guild.stage_channels,
|
||||||
|
*guild.threads,
|
||||||
|
]
|
||||||
|
|
||||||
|
for channel in channels:
|
||||||
|
if guild.me is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
permissions = channel.permissions_for(guild.me)
|
||||||
|
if not (
|
||||||
|
permissions.view_channel
|
||||||
|
and permissions.read_message_history
|
||||||
|
and permissions.manage_messages
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
deleted = await channel.purge(
|
||||||
|
limit=None,
|
||||||
|
after=cutoff,
|
||||||
|
check=lambda message: message.author.id == user_id,
|
||||||
|
reason="Honeypot cleanup",
|
||||||
|
)
|
||||||
|
if deleted:
|
||||||
|
print(f"Honeypot: removed {len(deleted)} message(s) in #{channel}")
|
||||||
|
except discord.HTTPException as error:
|
||||||
|
print(f"Honeypot: could not purge messages in #{channel}: {error}")
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_message(self, message: discord.Message):
|
||||||
|
if self.channel_id is None or message.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
parent_id = getattr(message.channel, "parent_id", None)
|
||||||
|
if message.channel.id != self.channel_id and parent_id != self.channel_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.bot.user is not None and message.author.id == self.bot.user.id:
|
||||||
|
return
|
||||||
|
|
||||||
|
reason = f"Honeypot triggered in #{message.channel.name}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
await message.delete()
|
||||||
|
except discord.HTTPException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
member = message.author
|
||||||
|
if not isinstance(member, discord.Member):
|
||||||
|
try:
|
||||||
|
member = await message.guild.fetch_member(member.id)
|
||||||
|
except discord.HTTPException:
|
||||||
|
print(f"Honeypot: could not resolve member {message.author.id}")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await member.kick(reason=reason)
|
||||||
|
print(f"Honeypot: kicked {member} ({member.id}) for posting in #{message.channel}")
|
||||||
|
except discord.Forbidden:
|
||||||
|
print(f"Honeypot: missing permissions to kick {member} ({member.id})")
|
||||||
|
except discord.HTTPException as error:
|
||||||
|
print(f"Honeypot: failed to kick {member} ({member.id}): {error}")
|
||||||
|
|
||||||
|
await self.purge_recent_user_messages(message.guild, member.id)
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot: commands.Bot):
|
||||||
|
await bot.add_cog(Honeypot(bot))
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import os
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
class JoinLeave(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_member_join(self, member):
|
||||||
|
if member.guild.id != int(os.getenv("GUILD_ID")):
|
||||||
|
return
|
||||||
|
|
||||||
|
channel = member.guild.get_channel(int(os.getenv("JOIN_LEAVE_CHANNEL_ID")))
|
||||||
|
if channel:
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Join👋",
|
||||||
|
description=f"Hey {member.mention} !\nWilkommen auf dem Server :3\nwelcome to the server :3",
|
||||||
|
color=3407664
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=member.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"Member count: {member.guild.member_count}")
|
||||||
|
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_member_remove(self, member):
|
||||||
|
if member.guild.id != int(os.getenv("GUILD_ID")):
|
||||||
|
return
|
||||||
|
|
||||||
|
channel = member.guild.get_channel(int(os.getenv("JOIN_LEAVE_CHANNEL_ID")))
|
||||||
|
if channel:
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Leave👋",
|
||||||
|
description=f"{member.mention} \nHat den Server verlassen :c\nhas left the server :c",
|
||||||
|
color=16711680
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=member.display_avatar.url)
|
||||||
|
embed.set_footer(text=f"Member count: {member.guild.member_count}")
|
||||||
|
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(JoinLeave(bot))
|
||||||
@@ -0,0 +1,358 @@
|
|||||||
|
import os
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands, tasks
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
raw_ticket_admin_ids = os.environ.get("TICKET_ADMIN_ROLE_IDS", "")
|
||||||
|
|
||||||
|
TICKET_ADMIN_ROLES = [int(role_id) for role_id in raw_ticket_admin_ids.split(",") if role_id]
|
||||||
|
|
||||||
|
class MemberSelectView(discord.ui.View):
|
||||||
|
def __init__(self, chosen_language: str):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
|
||||||
|
self.chosen_language = chosen_language
|
||||||
|
|
||||||
|
@discord.ui.select(
|
||||||
|
cls=discord.ui.UserSelect,
|
||||||
|
placeholder="Wählen Sie ein Mitglied aus...",
|
||||||
|
min_values=1,
|
||||||
|
max_values=1
|
||||||
|
)
|
||||||
|
async def select_callback(self, interaction: discord.Interaction, select: discord.ui.UserSelect):
|
||||||
|
chosen_member = select.values[0]
|
||||||
|
ticket_channel = interaction.channel
|
||||||
|
|
||||||
|
overwrites = ticket_channel.overwrites_for(chosen_member)
|
||||||
|
overwrites.view_channel = True
|
||||||
|
overwrites.read_message_history = True
|
||||||
|
|
||||||
|
await ticket_channel.set_permissions(chosen_member, overwrite=overwrites)
|
||||||
|
|
||||||
|
addUserText = f"{chosen_member.mention} wurde erfolgreich zu {ticket_channel.mention} hinzugefügt!" if self.chosen_language == "de" else f"Successfully added {chosen_member.mention} to {ticket_channel.mention}!"
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="INFO",
|
||||||
|
description=addUserText,
|
||||||
|
color=255
|
||||||
|
)
|
||||||
|
|
||||||
|
await ticket_channel.send(
|
||||||
|
embed=embed,
|
||||||
|
)
|
||||||
|
|
||||||
|
class TicketControlsView(discord.ui.View):
|
||||||
|
def __init__(self, chosen_language: str, ticket_channel):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
self.chosen_language = chosen_language
|
||||||
|
self.ticket_channel = ticket_channel
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _is_de(self) -> bool:
|
||||||
|
return self.chosen_language == "de"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _no_perm_msg(self) -> str:
|
||||||
|
return "Keine Berechtigungen für diese Aktion!" if self._is_de else "You do not have permission to do this!"
|
||||||
|
|
||||||
|
@discord.ui.button(label="Claim Ticket", style=discord.ButtonStyle.success, emoji="🙌", custom_id="claim_ticket")
|
||||||
|
async def claim_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
user_role_ids = [role.id for role in interaction.user.roles]
|
||||||
|
isAllowed = any(role_id in TICKET_ADMIN_ROLES for role_id in user_role_ids)
|
||||||
|
|
||||||
|
if isAllowed:
|
||||||
|
button.disabled = True
|
||||||
|
button.label = f"Claimed by {interaction.user.display_name}" if not self._is_de else f"Übernommen von {interaction.user.display_name}"
|
||||||
|
await interaction.response.edit_message(view=self)
|
||||||
|
|
||||||
|
claim_msg = (
|
||||||
|
f"{interaction.user.mention} hat dieses Ticket übernommen!"
|
||||||
|
if self._is_de else
|
||||||
|
f"{interaction.user.mention} has claimed this ticket!"
|
||||||
|
)
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="INFO",
|
||||||
|
description=claim_msg,
|
||||||
|
color=255
|
||||||
|
)
|
||||||
|
await interaction.followup.send(embed=embed, ephemeral=False)
|
||||||
|
|
||||||
|
bot = interaction.client
|
||||||
|
|
||||||
|
guild_id = int(os.getenv("GUILD_ID"))
|
||||||
|
category_id = int(os.getenv("TICKET_CLAIMED_CATEGORY_ID"))
|
||||||
|
|
||||||
|
guild = bot.get_guild(guild_id)
|
||||||
|
if not guild:
|
||||||
|
print("Error: Guild not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
category = guild.get_channel(category_id)
|
||||||
|
if not category or not isinstance(category, discord.CategoryChannel):
|
||||||
|
print("Error: Category not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
await interaction.message.channel.edit(category=category, sync_permissions=False)
|
||||||
|
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(self._no_perm_msg, ephemeral=True)
|
||||||
|
|
||||||
|
@discord.ui.button(label="Add User", style=discord.ButtonStyle.blurple, emoji="🫴", custom_id="add_user")
|
||||||
|
async def add_user_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
user_role_ids = [role.id for role in interaction.user.roles]
|
||||||
|
isAllowed = any(role_id in TICKET_ADMIN_ROLES for role_id in user_role_ids)
|
||||||
|
|
||||||
|
if isAllowed:
|
||||||
|
view = MemberSelectView(chosen_language=self.chosen_language)
|
||||||
|
prompt = (
|
||||||
|
"Bitte wählen Sie ein Mitglied aus der folgenden Liste aus:"
|
||||||
|
if self._is_de else
|
||||||
|
"Please select a member from the list below:"
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(prompt, view=view, ephemeral=True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(self._no_perm_msg, ephemeral=True)
|
||||||
|
|
||||||
|
@discord.ui.button(label="Close Ticket", style=discord.ButtonStyle.danger, emoji="🔒", custom_id="close_ticket")
|
||||||
|
async def close_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
close_msg = (
|
||||||
|
f"Ticket wurde von {interaction.user.mention} geschlossen!"
|
||||||
|
if self._is_de else
|
||||||
|
f"This ticket has been closed by {interaction.user.mention}!"
|
||||||
|
)
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="INFO",
|
||||||
|
description=close_msg,
|
||||||
|
color=255
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(embed=embed, ephemeral=False)
|
||||||
|
|
||||||
|
bot = interaction.client
|
||||||
|
|
||||||
|
guild_id = int(os.getenv("GUILD_ID"))
|
||||||
|
category_id = int(os.getenv("TICKET_CLOSED_CATEGORY_ID"))
|
||||||
|
|
||||||
|
guild = bot.get_guild(guild_id)
|
||||||
|
if not guild:
|
||||||
|
print("Error: Guild not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
category = guild.get_channel(category_id)
|
||||||
|
if not category or not isinstance(category, discord.CategoryChannel):
|
||||||
|
print("Error: Category not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
await interaction.message.channel.edit(category=category, sync_permissions=True)
|
||||||
|
#await interaction.channel.delete(reason="Ticket closed")
|
||||||
|
|
||||||
|
|
||||||
|
async def CreateTicketChannel(interaction: discord.Interaction, chosen_language, reason):
|
||||||
|
bot = interaction.client
|
||||||
|
|
||||||
|
guild_id = int(os.getenv("GUILD_ID"))
|
||||||
|
category_id = int(os.getenv("TICKET_UNCLAIMED_CATEGORY_ID"))
|
||||||
|
|
||||||
|
guild = bot.get_guild(guild_id)
|
||||||
|
if not guild:
|
||||||
|
print("Error: Guild not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
category = guild.get_channel(category_id)
|
||||||
|
if not category or not isinstance(category, discord.CategoryChannel):
|
||||||
|
print("Error: Category not found")
|
||||||
|
return None
|
||||||
|
|
||||||
|
db = await bot.database.get_conn()
|
||||||
|
|
||||||
|
cursor = await db.execute(
|
||||||
|
"INSERT INTO tickets (user_id, language, reason) VALUES (?, ?, ?)",
|
||||||
|
(interaction.user.id, chosen_language, reason)
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
num = cursor.lastrowid
|
||||||
|
num_str = f"{num:04d}"
|
||||||
|
|
||||||
|
emoji = "🇩🇪" if chosen_language == "de" else "🇺🇸"
|
||||||
|
channel_name = f"{emoji}-ticket-{num_str}"
|
||||||
|
|
||||||
|
ticket_channel = await category.create_text_channel(name=channel_name)
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
"UPDATE tickets SET ticket_channel_id = ? WHERE ticket_id = ?",
|
||||||
|
(ticket_channel.id, num)
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
if chosen_language == "de":
|
||||||
|
embed = discord.Embed(
|
||||||
|
description=f"""
|
||||||
|
# Ticket {num_str}
|
||||||
|
### Benutzer: {interaction.user.mention}
|
||||||
|
### Grund: ```{reason}```
|
||||||
|
""",
|
||||||
|
color=10289407
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
embed = discord.Embed(
|
||||||
|
description=f"""
|
||||||
|
# Ticket {num_str}
|
||||||
|
### User: {interaction.user.mention}
|
||||||
|
### Reason: ```{reason}```
|
||||||
|
""",
|
||||||
|
color=10289407
|
||||||
|
)
|
||||||
|
|
||||||
|
view = TicketControlsView(chosen_language=chosen_language, ticket_channel=ticket_channel)
|
||||||
|
|
||||||
|
await ticket_channel.send(
|
||||||
|
embed=embed,
|
||||||
|
view=view,
|
||||||
|
allowed_mentions=discord.AllowedMentions(users=False)
|
||||||
|
)
|
||||||
|
|
||||||
|
overwrites = ticket_channel.overwrites_for(interaction.user)
|
||||||
|
overwrites.view_channel = True
|
||||||
|
overwrites.read_message_history = True
|
||||||
|
await ticket_channel.set_permissions(interaction.user, overwrite=overwrites)
|
||||||
|
|
||||||
|
addUserText = f"{interaction.user.mention} wurde erfolgreich zu {ticket_channel.mention} hinzugefügt!" if chosen_language == "de" else f"Successfully added {interaction.user.mention} to {ticket_channel.mention}!"
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="INFO",
|
||||||
|
description=addUserText,
|
||||||
|
color=255
|
||||||
|
)
|
||||||
|
|
||||||
|
await ticket_channel.send(
|
||||||
|
embed=embed,
|
||||||
|
)
|
||||||
|
|
||||||
|
UserText = f"Hallo {interaction.user.mention}, wir kümmern uns in Kürze um Sie.\nIn der Zwischenzeit können Sie Ihr Problem näher beschreiben.\n<@&{os.getenv("TICKET_ADMIN_PING_ROLE_ID")}>" if chosen_language == "de" else f"Hello, {interaction.user.mention}. We will be with you shortly.\nIn the meantime, you can provide a more detailed description of your issue.\n<@&{os.getenv("TICKET_ADMIN_PING_ROLE_ID")}>"
|
||||||
|
|
||||||
|
await ticket_channel.send(UserText)
|
||||||
|
|
||||||
|
return ticket_channel
|
||||||
|
|
||||||
|
|
||||||
|
class CreateDETicketForm(discord.ui.Modal, title="Ticket erstellen"):
|
||||||
|
def __init__(self, chosen_language: str):
|
||||||
|
super().__init__()
|
||||||
|
self.chosen_language = chosen_language
|
||||||
|
|
||||||
|
form_reason = discord.ui.TextInput(
|
||||||
|
label="Warum erstellen Sie dieses Ticket?",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
placeholder="",
|
||||||
|
required=True,
|
||||||
|
max_length=400
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer(ephemeral=True)
|
||||||
|
|
||||||
|
ticket_channel = await CreateTicketChannel(interaction, self.chosen_language, self.form_reason.value)
|
||||||
|
|
||||||
|
if ticket_channel:
|
||||||
|
await interaction.followup.send(
|
||||||
|
f"✅ Das Ticket wurde erfolgreich erstellt: {ticket_channel.mention}",
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.followup.send(
|
||||||
|
"❌ Fehler beim Erstellen des Tickets. Bitte kontaktiere einen Admin.",
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateENTicketForm(discord.ui.Modal, title="Create a Ticket"):
|
||||||
|
def __init__(self, chosen_language: str):
|
||||||
|
super().__init__()
|
||||||
|
self.chosen_language = chosen_language
|
||||||
|
|
||||||
|
form_reason = discord.ui.TextInput(
|
||||||
|
label="Why are you creating this ticket?",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
placeholder="",
|
||||||
|
required=True,
|
||||||
|
max_length=400
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer(ephemeral=True)
|
||||||
|
|
||||||
|
ticket_channel = await CreateTicketChannel(interaction, self.chosen_language, self.form_reason.value)
|
||||||
|
|
||||||
|
if ticket_channel:
|
||||||
|
await interaction.followup.send(
|
||||||
|
f"✅ The ticket was successfully created: {ticket_channel.mention}",
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.followup.send(
|
||||||
|
"❌ Error creating the ticket. Please contact an admin.",
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
|
class LanguageSelect(discord.ui.Select):
|
||||||
|
def __init__(self):
|
||||||
|
options = [
|
||||||
|
discord.SelectOption(label="Deutsch", value="de", emoji="🇩🇪"),
|
||||||
|
discord.SelectOption(label="English", value="en", emoji="🇺🇸"),
|
||||||
|
]
|
||||||
|
super().__init__(placeholder="Sprache auswählen / Select language", min_values=1, max_values=1, options=options)
|
||||||
|
|
||||||
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
if self.values[0] == "de":
|
||||||
|
await interaction.response.send_modal(CreateDETicketForm(chosen_language=self.values[0]))
|
||||||
|
else:
|
||||||
|
await interaction.response.send_modal(CreateENTicketForm(chosen_language=self.values[0]))
|
||||||
|
|
||||||
|
await interaction.delete_original_response()
|
||||||
|
|
||||||
|
class LanguageDropdownView(discord.ui.View):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(timeout=60)
|
||||||
|
self.add_item(LanguageSelect())
|
||||||
|
|
||||||
|
class MainInteractiveMenu(discord.ui.View):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
|
||||||
|
@discord.ui.button(label="📩 Create ticket", style=discord.ButtonStyle.blurple)
|
||||||
|
async def primary_button_callback(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
|
await interaction.response.send_message(
|
||||||
|
content="Bitte wählen Sie Ihre Sprache aus, um fortzufahren:\nPlease select your language to continue:",
|
||||||
|
view=LanguageDropdownView(),
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
|
class Ticket(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
async def cog_load(self):
|
||||||
|
self.bot.add_view(TicketControlsView(chosen_language="en", ticket_channel=None))
|
||||||
|
self.startup.start()
|
||||||
|
|
||||||
|
def cog_unload(self):
|
||||||
|
self.startup.cancel()
|
||||||
|
|
||||||
|
@tasks.loop(count=1)
|
||||||
|
async def startup(self):
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
|
channel = await self.bot.fetch_channel(os.getenv("CREATE_TICKET_CHANNEL_ID"))
|
||||||
|
|
||||||
|
await channel.purge(limit=None, bulk=True)
|
||||||
|
|
||||||
|
await channel.send("""
|
||||||
|
# Support
|
||||||
|
Um ein Ticket zu erstellen, reagieren Sie mit 📩
|
||||||
|
To create a ticket react with 📩
|
||||||
|
""", view=MainInteractiveMenu())
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Ticket(bot))
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import discord
|
import discord
|
||||||
|
from cogs.database import Database
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
TOKEN = os.getenv('DISCORD_TOKEN')
|
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
intents.members = True
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix="Warum Kann das nicht weg??? :C", intents=intents)
|
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
|
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||||
print('------')
|
print("------")
|
||||||
|
|
||||||
|
await bot.database.connect()
|
||||||
|
print("Database connected!")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
synced = await bot.tree.sync()
|
synced = await bot.tree.sync()
|
||||||
@@ -23,16 +27,41 @@ async def on_ready():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to sync commands: {e}")
|
print(f"Failed to sync commands: {e}")
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_disconnect():
|
||||||
|
await bot.database.close()
|
||||||
|
|
||||||
|
|
||||||
async def load_extensions():
|
async def load_extensions():
|
||||||
for filename in os.listdir('./commands'):
|
for filename in os.listdir("./commands"):
|
||||||
if filename.endswith('.py'):
|
if filename.endswith(".py"):
|
||||||
await bot.load_extension(f'commands.{filename[:-3]}')
|
await bot.load_extension(f"commands.{filename[:-3]}")
|
||||||
print(f'Loaded extension: commands.{filename[:-3]}')
|
print(f"Loaded extension: commands.{filename[:-3]}")
|
||||||
|
|
||||||
|
for filename in os.listdir("./extensions"):
|
||||||
|
if filename.endswith(".py"):
|
||||||
|
await bot.load_extension(f"extensions.{filename[:-3]}")
|
||||||
|
print(f"Loaded extension: extensions.{filename[:-3]}")
|
||||||
|
|
||||||
|
if os.getenv("DEV_MODE") == "True":
|
||||||
|
for filename in os.listdir("./dev"):
|
||||||
|
if filename.endswith(".py"):
|
||||||
|
await bot.load_extension(f"dev.{filename[:-3]}")
|
||||||
|
print(f"Loaded extension: dev.{filename[:-3]}")
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with bot:
|
async with bot:
|
||||||
await load_extensions()
|
bot.database = Database()
|
||||||
await bot.start(TOKEN)
|
|
||||||
|
|
||||||
asyncio.run(main())
|
await load_extensions()
|
||||||
|
|
||||||
|
try:
|
||||||
|
await bot.start(os.getenv("DISCORD_TOKEN"))
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
asyncio.run(main())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("\nShutting down... byeeeeee :3 👋")
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
discord.py
|
||||||
|
aiosqlite
|
||||||
|
geopy
|
||||||
|
python-dotenv
|
||||||
|
simpleeval
|
||||||
Reference in new issue
Block a user