Running cogs in main.py

pull/8/head
sgoudham 4 years ago
parent 39fe656a4c
commit 27945c49eb

@ -12,9 +12,6 @@
# GNU General Public License for more details. # GNU General Public License for more details.
import datetime import datetime
import random import random
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from glob import glob
import aiohttp import aiohttp
import aiomysql import aiomysql
@ -24,6 +21,9 @@ from discord import Colour, Embed
from discord.ext import commands, tasks from discord.ext import commands, tasks
from discord.ext.commands import when_mentioned_or 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 <https://www.gnu.org/licenses/>.
counter = 0 counter = 0
# Get DB information from .env # Get DB information from .env
@ -531,10 +531,6 @@ class Bot(commands.Bot):
def run_bot(self): 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 # Run the bot, allowing it to come online
try: try:
self.run(API_TOKEN) self.run(API_TOKEN)

@ -16,8 +16,16 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Initiating Bot Object As Client # Initiating Bot Object As Client
from glob import glob
from bot.__init__ import Bot from bot.__init__ import Bot
client = 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 # Run the bot
client.run_bot() client.run_bot()

Loading…
Cancel
Save