Changing the organization of the project

This commit is contained in:
Rafael Vargas
2021-12-24 13:41:36 -04:00
parent d67997140f
commit 3639ba3280
10 changed files with 30 additions and 42 deletions

33
main.py
View File

@@ -1,23 +1,30 @@
import os
import discord
from dotenv import dotenv_values
from config import config
from discord.ext import commands
TOKEN_BOT = dotenv_values('.env')['TOKEN_BOT']
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!",
case_insensitive=True, intents=intents)
client.remove_command('help')
bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True,
case_insensitive=True, intents=intents)
bot.remove_command('help')
if __name__ == '__main__':
config.ABSOLUTE_PATH = os.path.dirname(os.path.abspath(__file__))
config.COOKIE_PATH = config.ABSOLUTE_PATH + config.COOKIE_PATH
if config.BOT_TOKEN == "":
print("Error: No bot token!")
exit()
for extension in config.INITIAL_EXTENSIONS:
try:
bot.load_extension(extension)
except Exception as e:
print(e)
def load_cogs(bot):
for filename in os.listdir('cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
load_cogs(client)
client.run(TOKEN_BOT)
bot.run(config.BOT_TOKEN, bot=True, reconnect=True)