-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
57 lines (41 loc) · 1.54 KB
/
bot.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import datetime
import logging
import asyncpg
import discord
from discord.ext import commands
import backend.config
import backend.logging
class Bot(commands.Bot):
def __init__(self, command_prefix, **options):
self.db = None
super().__init__(command_prefix, **options)
def reload_extension(self, name: str):
self.unload_extension(name)
self.load_extension(name)
async def start(self, *args, **kwargs):
self.db = await asyncpg.create_pool(user="postgres", host="inktober_postgres")
await super().start(*args, **kwargs)
inktober: Bot = Bot(command_prefix="b!", owner_id=240973228632178689)
inktober.load_extension("jishaku")
@inktober.event
async def on_ready():
log.info("On rewrite")
log.info(f"Connected at {datetime.datetime.now().strftime('%d %H:%M:%S')}")
log.info(f"Logged in as {inktober.user.name} {inktober.user.id}")
log.info("Connected to: ")
for server in inktober.guilds:
log.info(server.name)
await inktober.change_presence(
activity=discord.Game(name="Haunting blobkind"), status=None, afk=False
)
if __name__ == "__main__":
with backend.logging.setup_logging():
log = logging.getLogger(__name__)
try:
inktober.load_extension("backend.module_loader")
except Exception as E:
exc = "{}: {}".format(type(E).__name__, E)
log.error(
"Failed to load extension {}\n{}".format("backend.module_loader", exc)
)
inktober.run(backend.config.discord_token)