Bläddra i källkod

Added help_team.json file for the help team information and modified help_team.py to read from it.

baumsplitter41 4 månader sedan
förälder
incheckning
3785753d87
2 ändrade filer med 24 tillägg och 2 borttagningar
  1. 20 2
      VPD_BOT/cogs/help_team.py
  2. 4 0
      VPD_BOT/cogs/json_files/help_team.json

+ 20 - 2
VPD_BOT/cogs/help_team.py

@@ -1,3 +1,5 @@
+import json
+import os
 import discord
 from discord.ext import commands
 from discord.commands import slash_command
@@ -6,13 +8,29 @@ class helpteam(commands.Cog):
     def __init__(self, bot: discord.Bot):
         self.bot = bot
 
+
     @slash_command(name="help_how_to_team", description="Get Infos on how to join the Team")
     async def help_how_to_team(self, ctx: discord.ApplicationContext):
         server = ctx.guild
+
+        #Loading the JSON file
+        JSON_FILE_PATH = '.json_files/help_team.json'
+        if not os.path.exists(JSON_FILE_PATH):
+            await ctx.respond("The help_team.json file is missing.")
+            return
+        with open(JSON_FILE_PATH, 'r', encoding='utf-8') as f:
+            json_data = json.load(f)
+
+        for entry in json_data:
+            jstitle = entry.get("title", "")
+            jsdesc = entry.get("desc", "")
+
+
+
         
         embed = discord.Embed(
-            title=f"__How to join the Team on {server.name}__",
-            description="If you want to join the Serverteam open a ticket in #ticket.",
+            title=f"{jstitle}",
+            description=f"{jsdesc}",
             color=discord.Color.yellow()
         )
 

+ 4 - 0
VPD_BOT/cogs/json_files/help_team.json

@@ -0,0 +1,4 @@
+{ 
+     "title": "_How to join the Team on VicePD_",
+     "desc": "Um **dich** im team zu bewerben, muss du dich \n im support melden"  
+ }