forked from python-discord/code-jam-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
40 lines (29 loc) · 1.15 KB
/
run.py
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
# coding=utf-8
import os
from aiohttp import AsyncResolver, ClientSession, TCPConnector
from discord import Game
from discord.ext.commands import AutoShardedBot, when_mentioned_or
from bot.formatter import Formatter
from bot.utils import CaseInsensitiveDict
bot = AutoShardedBot(
command_prefix=when_mentioned_or(
">>> self.", ">> self.", "> self.", "self.",
">>> bot.", ">> bot.", "> bot.", "bot.",
">>> ", ">> ", "> ",
">>>", ">>", ">"
), # Order matters (and so do commas)
activity=Game(name="with snekky sneks"),
help_attrs={"aliases": ["help()"]},
formatter=Formatter()
)
# Make cog names case-insensitive
bot.cogs = CaseInsensitiveDict()
# Global aiohttp session for all cogs - uses asyncio for DNS resolution instead of threads, so we don't *spam threads*
bot.http_session = ClientSession(connector=TCPConnector(resolver=AsyncResolver()))
# Internal/debug
bot.load_extension("bot.cogs.logging")
bot.load_extension("bot.cogs.security")
# Commands, etc
bot.load_extension("bot.cogs.snakes")
bot.run(os.environ.get("BOT_TOKEN"))
bot.http_session.close() # Close the aiohttp session when the bot finishes running