import os, finnhub, platform, asyncio, discord from discord.ext import commands from discord_slash import SlashCommand from pymongo import MongoClient from funcs import Money, StarWars, Games, Other, LookupFuncs from utils import Options, Credentials, logThis, makeFiles, databaseFuncs 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?retryWrites=true&w=majority") if self.options.testing: self.log("Testing mode") self.database = self.MongoClient["Gwendolyn-Test"] else: self.database = self.MongoClient["Gwendolyn"] self.starWars = StarWars(self) self.other = Other(self) self.lookupFuncs = LookupFuncs(self) self.games = Games(self) self.money = Money(self) self.databaseFuncs = databaseFuncs(self) intents = discord.Intents.default() intents.members = True super().__init__(command_prefix=" ", case_insensitive=True, intents = intents, status = discord.Status.dnd) def log(self, messages, channel : str = "", level : int = 20): logThis(messages, channel, level) if __name__ == "__main__": if platform.system() == "Windows": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # Creates the required files makeFiles() # Creates the Bot bot = Gwendolyn() bot.slash = SlashCommand(bot, sync_commands=True, sync_on_cog_reload=True, override_type=True) #Loads cogs for filename in os.listdir("./cogs"): if filename.endswith(".py"): bot.load_extension(f"cogs.{filename[:-3]}") try: # Runs the whole shabang bot.run(bot.credentials.token) except: bot.log("Could not log in. Remember to write your bot token in the credentials.txt file")