Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
THEGOLDENPRO committed Apr 8, 2022
1 parent ec360cb commit 6c0d185
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/GoldyBot/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def insert(self, collection:str, data) -> bool:
return True

def find(self, collection:str, query:dict):
return self.database[collection].find(query)
return self.database[collection].find(query)

def list_collection_names(self):
return self.database.list_collection_names()
Expand All @@ -40,4 +40,8 @@ def find_one(self, collection:str, query:dict):
"""Tells database to search for and return specific data from a collection."""
data = self.database[collection].find_one(query)
GoldyBot.logging.log(f"[{MODULE_NAME}] Found '{query}' in '{collection}.'")
return data
return data

def create_collection(self, collection_name:str, data):
self.database[collection_name].insert_one(data)

7 changes: 3 additions & 4 deletions src/GoldyBot/utility/guilds/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ def setup(self):

# Create a database collection for the guild if there isn't already.
#--------------------------------------------------------------------
# Do ya thing. #TODO: Create database collection.
self.database #TODO: Add method to database to allow for creating collections.

self.database.create_collection(f"{self.code_name} (server)", {"_id":1,
"goldy":"I've created this collection automatically for a guild.",
"notice":"Feel free to delete this document."})

GoldyBot.logging.log("info_2", f"We setup the guild '{self.code_name}'.")
pass

@property
def id(self):
Expand Down

0 comments on commit 6c0d185

Please sign in to comment.