discord-bot-template/bot.py

38 lines
1,016 B
Python
Raw Normal View History

"""Bot startup code"""
2021-03-04 02:49:11 +00:00
import logging
from pathlib import Path
2021-03-04 02:49:11 +00:00
from discord.ext import commands
from applog.utils import read_logging_config, setup_logging
2021-03-04 02:49:11 +00:00
import core.common as common
logger = logging.getLogger(__name__)
discord_logger = logging.getLogger('discord')
log_config_dict = read_logging_config("applog/logging.yaml")
setup_logging(log_config_dict)
common.prompt_config("config.json", "Enter repository URL: ", "repo_link")
common.prompt_config("config.json", "Enter bot token: ", "token")
common.prompt_config("config.json", "Enter bot prefix: ", "prefix")
config, _ = common.load_config("config.json")
bot = commands.Bot(command_prefix=config['prefix'])
def get_extensions():
"""Gets extension list dynamically"""
2021-03-04 02:49:11 +00:00
extensions = []
for file in Path("cogs").glob("**/*.py"):
extensions.append(str(file).replace("/", ".").replace(".py", ""))
return extensions
for ext in get_extensions():
bot.load_extension(ext)
logger.info("starting bot.")
bot.run(config['token'])