mekasu0124

Untitled

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