From 27945c49eb5a757fb875673a13d70b342f66dd0c Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 17 Aug 2020 01:06:02 +0100 Subject: [PATCH] Running cogs in main.py --- bot/__init__.py | 10 +++------- main.py | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index c6202396..32d45b75 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -12,9 +12,6 @@ # GNU General Public License for more details. import datetime import random -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from glob import glob import aiohttp import aiomysql @@ -24,6 +21,9 @@ from discord import Colour, Embed from discord.ext import commands, tasks from discord.ext.commands import when_mentioned_or +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + counter = 0 # Get DB information from .env @@ -531,10 +531,6 @@ class Bot(commands.Bot): def run_bot(self): - cogs = [path.split("\\")[-1][:-3] for path in glob("./cogs/*.py")] - for ext in cogs: - self.load_extension(f"cogs.{ext}") - # Run the bot, allowing it to come online try: self.run(API_TOKEN) diff --git a/main.py b/main.py index b359f5ae..3e986b46 100644 --- a/main.py +++ b/main.py @@ -16,8 +16,16 @@ # along with this program. If not, see . # Initiating Bot Object As Client +from glob import glob + from bot.__init__ import Bot client = Bot() + +if __name__ == "__main__": + cogs = [path.split("\\")[-1][:-3] for path in glob("./cogs/*.py")] + for ext in cogs: + client.load_extension(f"cogs.{ext}") + # Run the bot client.run_bot()