diff --git a/.env.example b/.env.example index 5667101..03f9124 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,3 @@ API_HOST=127.0.0.1 API_PORT=5000 API_DEBUG=False API_SECRET_KEY=votre-cle-secrete-api - -# Partner Server IDs (for API) -PARTNER_IDS=111111111111111111,222222222222222222,333333333333333333 diff --git a/src/api/__init__.py b/src/api/__init__.py index 299a188..2c3a71d 100644 --- a/src/api/__init__.py +++ b/src/api/__init__.py @@ -4,6 +4,6 @@ Provides REST API endpoints for bot functionality """ from .app import APIManager -from .config import APIConfig, PARTNER_IDS +from .config import APIConfig -__all__ = ['APIManager', 'APIConfig', 'PARTNER_IDS'] +__all__ = ['APIManager', 'APIConfig'] diff --git a/src/api/config.py b/src/api/config.py index 0a55bfe..df42c5a 100644 --- a/src/api/config.py +++ b/src/api/config.py @@ -13,10 +13,3 @@ class APIConfig: PORT = int(os.getenv("API_PORT", 5000)) DEBUG = os.getenv("API_DEBUG", "False").lower() == "true" SECRET_KEY = os.getenv("API_SECRET_KEY", "votre-cle-secrete-api") - -# Partner server IDs for the API -PARTNER_IDS = [ - 111111111111111111, # ID serveur partenaire 1 - 222222222222222222, # ID serveur partenaire 2 - 333333333333333333, # ID serveur partenaire 3 -] diff --git a/src/api/routes.py b/src/api/routes.py index ae105f6..1923221 100644 --- a/src/api/routes.py +++ b/src/api/routes.py @@ -3,7 +3,6 @@ API routes for Kuby Discord bot """ from flask import jsonify -from .config import PARTNER_IDS def setup_routes(app, bot): @@ -23,33 +22,9 @@ def setup_routes(app, bot): "avatar_url": str(user.display_avatar.url) if user.display_avatar else "https://cdn.discordapp.com/embed/avatars/0.png", }) - @app.route("/api/partners") - def get_partners(): - """Get partner server information""" - partners = [] - for guild_id in PARTNER_IDS: - guild = bot.get_guild(guild_id) - if guild: - partners.append({ - "name": guild.name, - "icon_url": guild.icon.url if guild.icon else None, - "member_count": guild.member_count - }) - return jsonify(partners) - - @app.route("/api/status") - def get_status(): - """Get bot status and basic information""" - return jsonify({ - "status": "online" if bot.is_ready() else "connecting", - "username": bot.user.name if bot.user else "Unknown", - "guild_count": len(bot.guilds), - "total_members": sum(guild.member_count for guild in bot.guilds) if bot.guilds else 0 - }) - @app.route("/api/guilds") def get_guilds(): - """Get basic information about all guilds the bot is in""" + """Get all guilds where the bot is present""" guilds_info = [] for guild in bot.guilds: guilds_info.append({ @@ -57,6 +32,66 @@ def setup_routes(app, bot): "name": guild.name, "icon_url": guild.icon.url if guild.icon else None, "member_count": guild.member_count, - "owner_id": guild.owner_id + "owner_id": guild.owner_id, + "description": guild.description if guild.description else None, + "features": list(guild.features) if guild.features else [], + "created_at": guild.created_at.isoformat() if guild.created_at else None }) return jsonify(guilds_info) + + @app.route("/api/guild/") + def get_guild(guild_id): + """Get specific guild information by ID""" + guild = bot.get_guild(guild_id) + if not guild: + return jsonify({"error": "Serveur non trouvé"}), 404 + + return jsonify({ + "id": guild.id, + "name": guild.name, + "icon_url": guild.icon.url if guild.icon else None, + "member_count": guild.member_count, + "owner_id": guild.owner_id, + "description": guild.description if guild.description else None, + "features": list(guild.features) if guild.features else [], + "created_at": guild.created_at.isoformat() if guild.created_at else None, + "channels": [ + { + "id": channel.id, + "name": channel.name, + "type": str(channel.type), + "category": channel.category.name if channel.category else None + } + for channel in guild.channels + ], + "roles": [ + { + "id": role.id, + "name": role.name, + "color": role.color, + "position": role.position, + "member_count": len(role.members) + } + for role in guild.roles + ] + }) + + @app.route("/api/status") + def get_status(): + """Get bot status and basic information""" + return jsonify({ + "status": "online" if bot.is_ready() else "connecting", + "username": bot.user.name if bot.user else "Unknown", + "user_id": bot.user.id if bot.user else None, + "guild_count": len(bot.guilds), + "total_members": sum(guild.member_count for guild in bot.guilds) if bot.guilds else 0, + "total_channels": sum(len(guild.channels) for guild in bot.guilds) if bot.guilds else 0, + "uptime": "N/A", # TODO: Implement uptime tracking + "version": "2.0.0", + "api_endpoints": [ + "/api/user/", + "/api/guilds", + "/api/guild/", + "/api/status" + ] + })