Added database thing

This commit is contained in:
NikolajDanger
2020-08-12 21:08:35 +02:00
parent 1a459fffb0
commit 7afb7454f8
4 changed files with 38 additions and 7 deletions

View File

@ -1,8 +1,8 @@
import discord, os, finnhub
import discord, os, finnhub, pymongo
from discord.ext import commands
from funcs import logThis, makeFiles
from pymongo import MongoClient
from funcs import logThis, makeFiles, transferUsers
commandPrefix = "!"
@ -14,12 +14,24 @@ class Credentials():
self.token = data[0][10:].replace(" ","")
self.finnhubKey = data[1][16:].replace(" ","")
self.wordnikKey = data[2][16:].replace(" ","")
self.mongoDBUser = data[3][13:].replace(" ","")
self.mongoDBPassword = data[4][17:].replace(" ","")
class Options():
def __init__(self):
with open("options.txt","r") as f:
data = f.read().splitlines()
self.prefix = data[0][7:].replace(" ","")
self.testing = bool(data[1][8:].replace(" ",""))
class Gwendolyn(commands.Bot):
def __init__(self):
self.options = Options()
self.credentials = Credentials()
self.finnhubClient = finnhub.Client(api_key = self.credentials.finnhubKey)
self.MongoClient = MongoClient(f"mongodb+srv://{self.credentials.mongoDBUser}:{self.credentials.mongoDBPassword}@gwendolyn.qkwfy.mongodb.net/Gwendolyn-Test?retryWrites=true&w=majority")
self.database = self.MongoClient["Gwendolyn-Test"]
super().__init__(command_prefix=commandPrefix, case_insensitive=True)
# Creates the required files
@ -28,6 +40,9 @@ makeFiles()
# Creates the Bot
client = Gwendolyn()
# Creates database collections
transferUsers(client.database)
# Logs in
@client.event
async def on_ready():