Files
TuneBot/utils/database.py
T
2021-11-02 22:51:30 +01:00

21 lines
658 B
Python

from aioredis import Redis
from typing import Sequence
class AutoJoin:
@staticmethod
async def get_channels(redis: Redis) -> Sequence[tuple]:
# return all channels
channels = await redis.hgetall(name="autojoin")
return {key: value.split("-") for key, value in channels.items()}
@staticmethod
async def update_channel(redis: Redis, guild_id, voicechannel_id, textchannel_id):
await redis.hset(
name="autojoin", key=guild_id, value=f"{voicechannel_id}-{textchannel_id}"
)
@staticmethod
async def del_channel(redis: Redis, guild_id):
await redis.hdel("autojoin", guild_id)