discord-bot/src/bot.py
bibin b8b8484466 Style: move commands up
Commands should be declared before loading further extensions
2020-12-27 22:47:10 +01:00

52 lines
1,006 B
Python

"""
This is the main module of the Discord Bot
Mainly loads the Cog's and starts the bot
"""
__version__ = '0.5'
__author__ = 'Bibin Muttappillil'
# standard library imports
import os
from dotenv import load_dotenv
# discord imports
from discord.ext import commands
# Token stuff
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
if TOKEN is None:
print("Missing discord token!")
exit(1)
bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b '))
@bot.command()
@commands.is_owner()
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
print(f'cogs.{extension} loaded')
@bot.command()
@commands.is_owner()
async def unload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
print(f'cogs.{extension} unloaded')
@bot.command()
@commands.is_owner()
async def reload(ctx, extension):
bot.reload_extension(f'cogs.{extension}')
print(f'cogs.{extension} reloaded')
for extension in ['developer']:
bot.load_extension(f'cogs.{extension}')
bot.run(TOKEN)