示例#1
0
def load_static_text(filename: str) -> str:
    """Load static text from a file."""
    logger = utils.get_logger()
    try:
        with open(Path(__file__).parent / "static" / filename) as f:
            return f.read()
    except FileNotFoundError:
        logger.warning("File %s not found.", filename)
        return ""
示例#2
0
 def __init__(self, client):
     """Initialize the cog."""
     self.client = client
     self.logger = utils.get_logger()
     self.logger.info("Module %s loaded", self.__class__.__name__)
示例#3
0
def test_logger():
    """Test that the logger can be accessed."""
    logger = get_logger()
    assert logger is not None
    logger.debug("Test was run successfully.")
示例#4
0
#!env/bin/python3
"""Main module to run the bot."""
from discord.ext import commands
from maho import config, models, utils

# Logging
logger = utils.get_logger()

# Model setup
models.setup_tables()

# State
loaded_modules = []
client = commands.Bot(command_prefix=config.PREFIX, description=config.DESCRIPTION)


@client.event
async def on_ready():
    """Handle what happens when the bot is ready."""
    print(f"Logged in as {client.user.name} - {client.user.id}")

    print(f"------ Guilds ({len(client.guilds)}) ------")
    for guild in client.guilds:
        print(guild.name)

    print(f"------ Loading Modules ({len(config.STARTUP)}) ------")
    for module in config.STARTUP:
        if await utils.load_module(client, module):
            loaded_modules.append(module)