2024-08-09 22:28:02 +01:00
|
|
|
"""
|
|
|
|
matchy.py - Discord bot that matches people into groups
|
|
|
|
"""
|
2024-08-08 23:32:52 +01:00
|
|
|
import logging
|
2024-08-09 22:28:02 +01:00
|
|
|
import discord
|
2024-08-13 20:12:48 +01:00
|
|
|
from discord.ext import commands
|
2024-08-10 10:45:44 +01:00
|
|
|
import config
|
2024-08-13 23:24:14 +01:00
|
|
|
from state import load_from_file
|
2024-08-13 22:42:52 +01:00
|
|
|
from cogs.matchy_cog import MatchyCog
|
|
|
|
from cogs.owner_cog import OwnerCog
|
2024-08-10 10:06:13 +01:00
|
|
|
|
2024-08-13 23:45:18 +01:00
|
|
|
_STATE_FILE = "state.json"
|
|
|
|
state = load_from_file(_STATE_FILE)
|
2024-08-07 23:23:52 +01:00
|
|
|
|
2024-08-08 23:32:52 +01:00
|
|
|
logger = logging.getLogger("matchy")
|
|
|
|
logger.setLevel(logging.INFO)
|
|
|
|
|
2024-08-07 22:15:39 +01:00
|
|
|
intents = discord.Intents.default()
|
|
|
|
intents.message_content = True
|
2024-08-07 23:23:52 +01:00
|
|
|
intents.members = True
|
2024-08-09 22:12:58 +01:00
|
|
|
bot = commands.Bot(command_prefix='$',
|
|
|
|
description="Matchy matches matchees", intents=intents)
|
|
|
|
|
2024-08-07 22:15:39 +01:00
|
|
|
|
2024-08-11 11:37:20 +01:00
|
|
|
@bot.event
|
|
|
|
async def setup_hook():
|
2024-08-13 23:24:14 +01:00
|
|
|
await bot.add_cog(MatchyCog(bot, state))
|
|
|
|
await bot.add_cog(OwnerCog(bot, state))
|
2024-08-11 11:37:20 +01:00
|
|
|
|
|
|
|
|
2024-08-08 00:09:30 +01:00
|
|
|
@bot.event
|
|
|
|
async def on_ready():
|
2024-08-13 20:12:48 +01:00
|
|
|
logger.info("Logged in as %s", bot.user.name)
|
2024-08-07 23:23:52 +01:00
|
|
|
|
2024-08-09 22:12:58 +01:00
|
|
|
|
2024-08-09 23:14:42 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
handler = logging.StreamHandler()
|
2024-08-11 22:07:43 +01:00
|
|
|
bot.run(config.Config.token, log_handler=handler, root_logger=True)
|