mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 21:27:48 +00:00
36 lines
1014 B
Python
36 lines
1014 B
Python
from typing import Dict
|
|
from typing import List
|
|
from typing import Optional
|
|
|
|
from aioredis import Redis
|
|
|
|
from bot import redis_prefix
|
|
|
|
|
|
class AutoJoin:
|
|
@staticmethod
|
|
async def get_channels(redis: Redis) -> Dict[str, str]:
|
|
# return all channels
|
|
channels = await redis.hgetall(f"{redis_prefix}:autojoin")
|
|
return {key: value.split("-") for key, value in channels.items()}
|
|
|
|
@staticmethod
|
|
async def update_channel(
|
|
redis: Redis, guild_id: int, voice_channel_id: int, text_channel_id: int
|
|
):
|
|
await redis.hset(
|
|
f"{redis_prefix}:autojoin",
|
|
guild_id,
|
|
f"{voice_channel_id}-{text_channel_id}",
|
|
)
|
|
|
|
@staticmethod
|
|
async def del_channel(redis: Redis, guild_id: int):
|
|
await redis.hdel(f"{redis_prefix}:autojoin", guild_id)
|
|
|
|
|
|
class Playlist:
|
|
@staticmethod
|
|
async def random(redis: Redis, amount: Optional[int] = 1) -> List[str]:
|
|
return await redis.srandmember(f"{redis_prefix}:playlist", amount)
|