Add autojoin feature

This commit is contained in:
2021-11-02 22:51:30 +01:00
parent eddc557f81
commit cdf848d87d
3 changed files with 78 additions and 28 deletions
+20
View File
@@ -0,0 +1,20 @@
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)