WIP Cleaning up the code base + impl slash commands

This commit is contained in:
2021-10-30 22:05:40 +02:00
parent 425d3a3a92
commit bcf3d957a8
16 changed files with 973 additions and 541 deletions
-32
View File
@@ -1,32 +0,0 @@
import aiomysql
import asyncio
from bot import CloudKid
from aiomysql.sa import SAConnection
from sqlalchemy import Table
from typing import Sequence
class AutoJoin:
@staticmethod
async def get_channels(bot: CloudKid) -> Sequence[tuple]:
autojoin: Table = bot.database.tables["autojoin"]
conn: SAConnection = await bot.database.engine.acquire()
result = await conn.execute(autojoin.select())
channels: Sequence[tuple] = await result.fetchall()
return channels
@staticmethod
async def update_channel(bot, guild_id, channel_id):
autojoin: Table = bot.database.tables["autojoin"]
conn: SAConnection = await bot.database.engine.acquire()
await conn.execute(autojoin.insert().values({
"guild_id": guild_id,
"channel_id": channel_id
}))
@staticmethod
async def del_channel(bot, guild_id):
autojoin: Table = bot.database.tables["autojoin"]
conn: SAConnection = await bot.database.engine.acquire()
await conn.execute(
autojoin.delete().where(autojoin.c.guild_id == guild_id))