mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-09-09 11:15:08 +08:00
initial bot structure
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
"""Bot logic."""
|
||||
import hikari
|
||||
|
||||
import aiosqlite
|
||||
import lightbulb
|
||||
import miru
|
||||
from bot.config import Config
|
||||
|
||||
config = Config.from_env()
|
||||
|
||||
bot = lightbulb.BotApp(
|
||||
token=config.token,
|
||||
logs="DEBUG",
|
||||
prefix="./",
|
||||
default_enabled_guilds=config.declare_global_commands,
|
||||
owner_ids=config.owner_ids,
|
||||
intents=hikari.Intents.ALL,
|
||||
)
|
||||
|
||||
|
||||
@bot.listen()
|
||||
async def on_starting(event: hikari.StartingEvent):
|
||||
"""Setup."""
|
||||
|
||||
miru.install(bot) # component handler
|
||||
bot.load_extensions_from("./bot/extensions") # load extensions
|
||||
|
||||
bot.d.db = await aiosqlite.connect(":memory:") # TODO: Update
|
||||
await bot.d.db.executescript(open("./bot/db/schema.sql").read())
|
||||
await bot.d.db.commit()
|
||||
|
||||
|
||||
@bot.listen()
|
||||
async def on_stopping(event: hikari.StoppingEvent):
|
||||
"""Cleanup."""
|
||||
await bot.d.db.close()
|
||||
Reference in New Issue
Block a user