37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import asyncio
|
|
import discord
|
|
from discord.ext import commands
|
|
from chorus_bot.config import load_config
|
|
from chorus_bot.backend_client import BackendClient
|
|
from chorus_bot.cogs.manual_share import setup as setup_manual_share
|
|
from chorus_bot.cogs.email_ingest import setup as setup_email_ingest
|
|
from chorus_bot.cogs.thread_ingest import setup as setup_thread_ingest
|
|
from chorus_bot.cogs.subscribe import setup as setup_subscribe
|
|
|
|
|
|
def build_bot() -> commands.Bot:
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
intents.members = True
|
|
return commands.Bot(command_prefix="!", intents=intents)
|
|
|
|
|
|
async def main():
|
|
config = load_config()
|
|
bot = build_bot()
|
|
backend_client = BackendClient(config.backend_base_url)
|
|
|
|
@bot.event
|
|
async def on_ready():
|
|
await setup_manual_share(bot, config)
|
|
await setup_email_ingest(bot, config)
|
|
await setup_thread_ingest(bot, config, backend_client)
|
|
await setup_subscribe(bot, config)
|
|
await bot.tree.sync(guild=discord.Object(id=config.guild_id))
|
|
print(f"Chorus bot ready as {bot.user}")
|
|
|
|
await bot.start(config.discord_token)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|