help_team.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import json
  2. import os
  3. import discord
  4. from discord.ext import commands
  5. from discord.commands import slash_command
  6. class helpteam(commands.Cog):
  7. def __init__(self, bot: discord.Bot):
  8. self.bot = bot
  9. @slash_command(name="help_team", description="Get Infos on how to join the Team")
  10. async def help_team(self, ctx: discord.ApplicationContext):
  11. server = ctx.guild
  12. #Loading the JSON file
  13. JSON_FILE_PATH = 'cogs/json_files/help_team.json'
  14. if not os.path.exists(JSON_FILE_PATH):
  15. await ctx.respond("The help_team.json file is missing.")
  16. return
  17. with open(JSON_FILE_PATH, 'r', encoding='utf-8') as f:
  18. json_data = json.load(f)
  19. for entry in json_data:
  20. jstitle = entry.get("title", "")
  21. jsdesc = entry.get("desc", "")
  22. embed = discord.Embed(
  23. title=f"{jstitle}",
  24. description=f"{jsdesc}",
  25. color=discord.Color.yellow()
  26. )
  27. if server.icon:
  28. embed.set_thumbnail(url=server.icon.url)
  29. embed.set_author(name="VicePD", icon_url="https://i.imgur.com/6QteFrg.png")
  30. embed.set_footer(text="VicePD - Bot | Made by BaumSplitter41")
  31. await ctx.respond(embed=embed)
  32. def setup(bot: discord.Bot):
  33. bot.add_cog(helpteam(bot))