Ooglely / pugBot

Discord bot to run TF2 pick up games | pugbot.tf
https://pugbot.tf
21 stars 1 forks source link

Restructuring database.py #23

Open Ooglely opened 10 months ago

Ooglely commented 10 months ago

While restructuring the way the pug categories were stored I also made a class for interacting with the bot's database, without needing the 20+ functions that were specific to one purpose in database.py. Having every feature that uses the database use the BotCollection class instead would look and work much better

from database import BotCollection

category_db = BotCollection("guilds", "categories")

# Get a list of pug categories
try:
  result = await category_db.find_item({"_id": interaction.guild.id})
except LookupError:
  await interaction.send(
    "There are no pug categories setup for this server.\nPlease run /pug category add to add a pug category."
  )
  return