mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 21:27:48 +00:00
Add autojoin feature
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user