From 6efcc1426344279b0a83cc1e5254367eda3fde7d Mon Sep 17 00:00:00 2001 From: Medicopter117 Date: Sat, 28 Mar 2026 21:20:24 +0100 Subject: [PATCH] feat: implement dashboard API routes and web settings components with associated documentation --- docs/source/dev_guide/api/getting_started.rst | 8 ++++ .../dev_guide/api/publics_endpoints.rst | 15 ++++++ .../getting_started/fast_setting_up.rst | 0 docs/source/dev_guide/index.rst | 17 +++---- docs/source/index.rst | 12 ++++- src/api/dashboard/routes.py | 48 ++++++++++++++++--- src/web/components/AntiSpamSettings.tsx | 2 +- src/web/components/GlobalChatSettings.tsx | 2 +- src/web/components/WelcomeSettings.tsx | 2 +- 9 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 docs/source/dev_guide/api/getting_started.rst create mode 100644 docs/source/dev_guide/api/publics_endpoints.rst delete mode 100644 docs/source/dev_guide/getting_started/fast_setting_up.rst diff --git a/docs/source/dev_guide/api/getting_started.rst b/docs/source/dev_guide/api/getting_started.rst new file mode 100644 index 0000000..2b92ac7 --- /dev/null +++ b/docs/source/dev_guide/api/getting_started.rst @@ -0,0 +1,8 @@ +Getting Start with the API! +========================================================== + +Getting Start with the API is easy. You can use the API to get information about the bot and its features. You can also use the API to get information about the bot's features. You can also use the API to get information about the bot's features. + +first read this: + +`→ Open Publics Endpoints `_ \ No newline at end of file diff --git a/docs/source/dev_guide/api/publics_endpoints.rst b/docs/source/dev_guide/api/publics_endpoints.rst new file mode 100644 index 0000000..f994e6d --- /dev/null +++ b/docs/source/dev_guide/api/publics_endpoints.rst @@ -0,0 +1,15 @@ +Publics Endpoints +========================================================== + +All Publics Endpoints of ManagerX. + ++------------+------------+------------+--------------------------------------+ +| Endpoint | Method | Description | ++============+============+============+======================================+ +| /v1/managerx/stats | GET | Returns the stats of the bot | ++------------+------------+------------+--------------------------------------+ +| /v1/managerx/leaderboard| GET | Returns the leaderboard of the bot | ++------------+------------+------------+--------------------------------------+ +| /v1/managerx/version | GET | Returns the version of the bot | ++------------+------------+------------+--------------------------------------+ + diff --git a/docs/source/dev_guide/getting_started/fast_setting_up.rst b/docs/source/dev_guide/getting_started/fast_setting_up.rst deleted file mode 100644 index e69de29..0000000 diff --git a/docs/source/dev_guide/index.rst b/docs/source/dev_guide/index.rst index ca285ed..45f0325 100644 --- a/docs/source/dev_guide/index.rst +++ b/docs/source/dev_guide/index.rst @@ -1,15 +1,12 @@ -Developer Guide -====================== +Welcome to the Developer Guide for ManagerX. +========================================================== -Welcome to the ManagerX Developer Guide! This guide provides everything you need to understand the inner workings of ManagerX, contribute to its development, and extend its functionality. - -Whether you're looking to set up a local development environment, explore the architecture, build new features, or deploy your own instance — you'll find all the information here. +learn about the API, the Dashboard, the Bot and more. .. toctree:: :maxdepth: 2 - :caption: Contents + :caption: API: - Quick Start - architecture/index - contributing/index - deployment/index \ No newline at end of file + Getting Started + Public Endpoints + \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index b5a6e24..9e59556 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -180,4 +180,14 @@ We welcome contributions from the community! Whether it's bug reports, feature r --- **© 2026 ManagerX Development** -*Version 2.0.0-dev | Last Updated: December 7, 2025* \ No newline at end of file +*Version 2.0.0-dev | Last Updated: December 7, 2025* + +.. toctree:: + :maxdepth: 2 + :caption: User Guide: + + user_guide/index + :maxdepth: 2 + :caption: Developer Guide: + + Developer Guide \ No newline at end of file diff --git a/src/api/dashboard/routes.py b/src/api/dashboard/routes.py index ef77fc4..21c7e7d 100644 --- a/src/api/dashboard/routes.py +++ b/src/api/dashboard/routes.py @@ -163,7 +163,13 @@ async def get_guild_channels(guild_id: int, user: dict = Depends(get_current_use # Check if user is in guild and has appropriate permissions (Manage Guild or Admin) member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") channels = [ @@ -183,7 +189,13 @@ async def get_guild_roles(guild_id: int, user: dict = Depends(get_current_user)) raise HTTPException(status_code=404, detail="Guild not found or bot not in guild") member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") roles = [ @@ -203,7 +215,13 @@ async def get_guild_categories(guild_id: int, user: dict = Depends(get_current_u raise HTTPException(status_code=404, detail="Guild not found or bot not in guild") member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") categories = [ @@ -223,7 +241,13 @@ async def get_guild_voice_channels(guild_id: int, user: dict = Depends(get_curre raise HTTPException(status_code=404, detail="Guild not found or bot not in guild") member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") channels = [ @@ -243,7 +267,13 @@ async def get_guild_stats(guild_id: int, user: dict = Depends(get_current_user)) raise HTTPException(status_code=404, detail="Guild not found or bot not in guild") member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") # Fetch daily growth/activity @@ -344,7 +374,13 @@ async def get_mega_data(guild_id: int, user: dict = Depends(get_current_user)): raise HTTPException(status_code=404, detail="Guild not found or bot not in guild") member = guild.get_member(int(user["id"])) - if not member or not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): + if not member: + try: + member = await guild.fetch_member(int(user["id"])) + except: + raise HTTPException(status_code=403, detail="Nutzer nicht auf dem Server gefunden") + + if not (member.guild_permissions.manage_guild or member.guild_permissions.administrator): raise HTTPException(status_code=403, detail="Insufficient permissions") try: diff --git a/src/web/components/AntiSpamSettings.tsx b/src/web/components/AntiSpamSettings.tsx index d09914a..5533674 100644 --- a/src/web/components/AntiSpamSettings.tsx +++ b/src/web/components/AntiSpamSettings.tsx @@ -38,7 +38,7 @@ export default function AntiSpamSettings({ guildId }: { guildId: string }) { const baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8040'; // Fetch Channels - const channelRes = await fetch(`${baseUrl}/dashboard/settings/${guildId}/channels`, { + const channelRes = await fetch(`${baseUrl}/dashboard/guilds/${guildId}/channels`, { headers: { "Authorization": `Bearer ${token}` } }); if (channelRes.ok) { diff --git a/src/web/components/GlobalChatSettings.tsx b/src/web/components/GlobalChatSettings.tsx index 38bc0fe..b8edace 100644 --- a/src/web/components/GlobalChatSettings.tsx +++ b/src/web/components/GlobalChatSettings.tsx @@ -39,7 +39,7 @@ export default function GlobalChatSettings({ guildId }: { guildId: string }) { const baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8040'; // Fetch Channels - const channelRes = await fetch(`${baseUrl}/dashboard/settings/${guildId}/channels`, { + const channelRes = await fetch(`${baseUrl}/dashboard/guilds/${guildId}/channels`, { headers: { "Authorization": `Bearer ${token}` } }); if (channelRes.ok) { diff --git a/src/web/components/WelcomeSettings.tsx b/src/web/components/WelcomeSettings.tsx index b8e11a4..f296d44 100644 --- a/src/web/components/WelcomeSettings.tsx +++ b/src/web/components/WelcomeSettings.tsx @@ -48,7 +48,7 @@ export default function WelcomeSettings({ guildId }: { guildId: string }) { const base = "http://localhost:8040/dashboard/settings"; // Fetch Channels - const channelRes = await fetch(`${base}/${guildId}/channels`, { + const channelRes = await fetch(`http://localhost:8040/v1/managerx/dashboard/guilds/${guildId}/channels`, { headers: { "Authorization": `Bearer ${token}` } }); if (channelRes.ok) {