Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
908 changes: 147 additions & 761 deletions README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TOKEN=abc123
WEATHER_API=abc123
ERROR_WEBHOOK=https://discord.com/api/webhooks

DISCORD_CLIENT_ID=12345678900
DISCORD_CLIENT_SECRET=abc123
DISCORD_REDIRECT_URI=https://

URL=https://

DASHBOARD_API_KEYS=abc123
4 changes: 2 additions & 2 deletions examples/bot/cog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import discord
import ezcord

class Cog(ezcord.Cog): # Create a cog
class ExampleCog(ezcord.Cog): # Create a cog
def __init__(self, bot): # Initialize the cog
self.bot = bot # Set the bot

def setup(bot):
bot.add_cog(Cog(bot)) # Add the cog to the bot
bot.add_cog(ExampleCog(bot)) # Add the cog to the bot
4 changes: 2 additions & 2 deletions examples/bot/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from discord import slash_command
import ezcord

class Embeds(ezcord.Cog):
class ExampleEmbeds(ezcord.Cog):
def __init__(self, bot):
self.bot = bot

Expand Down Expand Up @@ -32,4 +32,4 @@ async def embed(self, ctx):
await ctx.respond(embed=embed)

def setup(bot):
bot.add_cog(Embeds(bot)) # Add the Cog to the Bot
bot.add_cog(ExampleEmbeds(bot)) # Add the Cog to the Bot
4 changes: 2 additions & 2 deletions examples/bot/slash_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import ezcord
from discord import slash_command

class SlashCommand(ezcord.Cog):
class ExampleSlashCommand(ezcord.Cog):
def __init__(self, bot):
self.bot = bot

Expand All @@ -11,4 +11,4 @@ async def ping(self, ctx): # Define the slash command
await ctx.respond("Pong!") # Send a message

def setup(bot):
bot.add_cog(SlashCommand(bot))
bot.add_cog(ExampleSlashCommand(bot))
29 changes: 29 additions & 0 deletions examples/bot/views/buttons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import discord
from discord import slash_command
import ezcord

class ExampleButtonsCog(ezcord.Cog):
def __init__(self, bot: ezcord.Bot):
self.bot = bot

@slash_command(description="Button Example")
async def buttons(self, ctx):
await ctx.respond("Click here:", view=ExampleButtonView()) # Send the button

async def setup(bot):
bot.add_cog(ExampleButtonsCog(bot))


class ExampleButtonView(discord.ui.View): # Create a view
def __init__(self):
super().__init__()

@discord.ui.button(label="Click Me", style=discord.ButtonStyle.primary) # Create a button
async def button_callback(self, button, interaction): # Define the button
await interaction.response.send_message("You clicked the button!") # Send a message

# Your can more Buttons adding in a View.

@discord.ui.button(label="Delete", style=discord.ButtonStyle.danger) # Create a button
async def delete_callback(self, button, interaction): # Define the button
await interaction.message.delete() # Delete the message
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# First import the Modul
import discord
from discord.ui import Container # Import the Container Modul
from discord.ui import Container # Import the Container Class
import ezcord

class ContainerExample(ezcord.Cog):
Expand All @@ -11,15 +11,12 @@ def __init__(self, bot):

@discord.slash_command(name="container", description="Zeigt ein Container an")
async def container(self, ctx: discord.ApplicationContext):
container = Container() # Define the Container
container = Container(color=discord.Color.blue()) # Define the Container with a color
container.add_text("## Hello World") # Add a Markdown Text to the Container
container.add_separator() # Add a Separator to the Container
container.add_text("Hello World") # Add a Text to the Container
view = discord.ui.DesignerView(container, timeout=0) # Define the View
await ctx.respond(view=view)
await ctx.respond(view=view) # Send the View

def setup(bot):
bot.add_cog(ContainerExample(bot)) # Add the Cog to the Bot



27 changes: 22 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

# API Routes für Dashboard
from src.api.dashboard.routes import set_bot_instance, router as dashboard_router
from mx_handler import TranslationHandler

# =============================================================================
# SETUP
Expand All @@ -43,6 +44,15 @@
load_dotenv(dotenv_path=BASEDIR / 'config' / '.env')
colorama_init(autoreset=True)

TranslationHandler.settings(
path="translation/messages",
default_lang="de",
fallback_langs=("en", "de"),
logging=False,
colored=False,
log_level="DEBUG"
)

# Sys-Path
if str(BASEDIR) not in sys.path:
sys.path.append(str(BASEDIR))
Expand Down Expand Up @@ -111,17 +121,16 @@ async def start_webserver():
dashboard = DashboardTask(bot, BASEDIR)
dashboard.register()

# Event Handler
@bot.event
async def on_ready():
logger.success("BOT", f"Logged in as {bot.user.name}")

# --- NEU: Status API & Webserver starten ---
bot.loop.create_task(start_webserver())

# Dashboard starten
dashboard.start()

# Bot-Status
if config['features'].get('bot_status', True):
await bot.change_presence(
Expand All @@ -130,11 +139,20 @@ async def on_ready():
name=f"ManagerX v{BotConfig.VERSION}"
)
)

# Commands sync
await bot.sync_commands()
logger.success("COMMANDS", "Application Commands synchronisiert")

# --- LIMIT CHECK START ---
all_cmds = bot.pending_application_commands
# Wir zählen nur die echten Top-Level Slash Commands (Slots)
root_slots = [c for c in all_cmds if isinstance(c, discord.SlashCommand)]

logger.info("LIMITS", f"EzCord zählt (alle Funktionen): {len(bot.commands)}")
logger.info("LIMITS", f"Discord-API Slots belegt: {len(root_slots)} / 100")
# --- LIMIT CHECK ENDE ---

# Minimaler KeepAlive Cog
class KeepAlive(discord.ext.commands.Cog):
def __init__(self, bot):
Expand All @@ -156,7 +174,6 @@ async def on_ready(self):
"src/bot/cogs",
subdirectories=True,
ignored_cogs=ignored,
log=CogLog.sum
)
logger.success("BOT", "Cogs geladen")

Expand Down
File renamed without changes.
36 changes: 35 additions & 1 deletion src/bot/cogs/bot/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform
import discord
from discord.ext import commands
import psutil
import ezcord
from mx_handler import TranslationHandler

Expand Down Expand Up @@ -33,7 +34,7 @@ async def about(self, ctx: discord.ApplicationContext):
member_count = sum(g.member_count for g in self.bot.guilds)

# Create Container
container = discord.ui.Container()
container = discord.ui.Container(color=discord.Color.red())

# Header
title = await TranslationHandler.get_for_user(self.bot, ctx.author.id, "cog_about.messages.title")
Expand Down Expand Up @@ -76,6 +77,39 @@ async def about(self, ctx: discord.ApplicationContext):
container.add_text(tech_info)
container.add_separator()

# System
system_header = await TranslationHandler.get_for_user(self.bot, ctx.author.id, "cog_about.messages.system_header")

# Gather System Info
os_info = f"{platform.system()} {platform.release()}"

memory = psutil.virtual_memory()
ram_info = f"{memory.used / (1024 ** 3):.2f} GB / {memory.total / (1024 ** 3):.2f} GB"

# CPU can be 0 on first call without interval, but blocking is bad.
# We'll stick to non-blocking.
cpu_usage = f"{psutil.cpu_percent()}%"

try:
if platform.system() == "Windows":
storage_info = "N/A"
else:
disk = psutil.disk_usage("/")
storage_info = f"{disk.used / (1024 ** 3):.2f} GB / {disk.total / (1024 ** 3):.2f} GB"
except Exception:
storage_info = "N/A"

system_info = await TranslationHandler.get_for_user(self.bot, ctx.author.id, "cog_about.messages.system_info",
os=os_info,
ram=ram_info,
cpu=cpu_usage,
storage=storage_info
)

container.add_text(system_header)
container.add_text(system_info)
container.add_separator()

# Footer
footer = await TranslationHandler.get_for_user(self.bot, ctx.author.id, "cog_about.messages.footer",
year=datetime.now().year,
Expand Down
Loading