aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/__main__.py
blob: 8b013b41af64bc202cf8a8eaffbd5384ebffc0b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Entrypoint for King Arthur."""

import asyncio

import aiohttp
import discord
from discord.ext import commands

import arthur
from arthur.bot import KingArthur
from arthur.config import CONFIG
from arthur.log import logger, setup_sentry


async def main() -> None:
    """Entry async method for starting the bot."""
    intents = discord.Intents.default()
    intents.message_content = True
    intents.members = True
    intents.dm_typing = False
    intents.dm_reactions = False
    intents.invites = False
    intents.webhooks = False
    intents.integrations = False

    async with aiohttp.ClientSession() as session:
        arthur.instance = KingArthur(
            guild_id=CONFIG.guild_id,
            http_session=session,
            command_prefix=commands.when_mentioned_or(*CONFIG.prefixes),
            allowed_roles=(CONFIG.devops_role,),
            case_insensitive=True,
            intents=intents,
        )
        async with arthur.instance as bot:
            await bot.start(CONFIG.token.get_secret_value())


setup_sentry()

with logger.catch():
    asyncio.run(main())