mekasu0124

Untitled

Feb 10th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.58 KB | None | 0 0
  1. import disnake
  2.  
  3. class Helpers:
  4.     def __init__(self):
  5.         super().__init__()
  6.  
  7.     async def get_embeds(self, db):
  8.         # create list of embeds that will be passed to the paginator
  9.         beginner = []
  10.         intermediate = []
  11.         web_scraping = []
  12.         automation = []
  13.         tkinter = []
  14.         turtle = []
  15.         opencv = []
  16.         py_django = []
  17.         python_tts = []
  18.         other = []
  19.  
  20.         # make a database call to obtain the list of tuples of all the projects
  21.         all_projects = db.get_projects()
  22.  
  23.         # iterate through each tuple in the list of tuples
  24.         for i in all_projects:
  25.             # unpack the tuple into it's variabels
  26.             iden, name, date, github_link, imgur_link, category = i
  27.  
  28.             # build the embed for the unpacked project
  29.             embed = disnake.Embed(
  30.                 color = disnake.Colour.random(),
  31.                 title = category,
  32.                 description = f"Project #{iden}"
  33.             ).add_field(
  34.                 name = "Project Name",
  35.                 value = name,
  36.                 inline = False
  37.             ).add_field(
  38.                 name = "Project Production Date",
  39.                 value = date,
  40.                 inline = False
  41.             ).add_field(
  42.                 name = "Project GitHub Link",
  43.                 value = github_link,
  44.                 inline = False
  45.             ).set_thumbnail(url=imgur_link)
  46.  
  47.             # determine which list the page gets added to based off the category
  48.             if category == "Beginner Projects":
  49.                 beginner.append(embed)
  50.             elif category == "Intermediate Projects":
  51.                 intermediate.append(embed)
  52.             elif category == "WebScraping Projects":
  53.                 web_scraping.append(embed)
  54.             elif category == "Automation Projects":
  55.                 automation.append(embed)
  56.             elif category == "TKinter Projects":
  57.                 tkinter.append(embed)
  58.             elif category == "Turtle Projects":
  59.                 turtle.append(embed)
  60.             elif category == "OpenCV Projects":
  61.                 opencv.append(embed)
  62.             elif category == "PythonDjango Projects":
  63.                 py_django.append(embed)
  64.             elif category == "Python Text To Speech Projects":
  65.                 python_tts.append(embed)
  66.             elif category == "Other Projects":
  67.                 other.append(embed)
  68.             else:
  69.                 raise
  70.  
  71.         return (embed, beginner, intermediate, web_scraping, automation, tkinter, turtle, opencv, py_django, python_tts, other)
Advertisement
Add Comment
Please, Sign In to add comment