mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 20:47:44 +00:00
database rewrite
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
import discord
|
||||
from discord.ext.commands import Context
|
||||
from discord import Embed
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
class EmbedGenerator:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Dict
|
||||
|
||||
from discord.ext.commands import Cog
|
||||
|
||||
from bot import TuneBot
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
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)
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
from discord.embeds import Embed
|
||||
from context import CustomContext
|
||||
from discord.ext.commands import CommandError
|
||||
|
||||
from context import CustomContext
|
||||
|
||||
|
||||
class EmbeddedCommandException(CommandError):
|
||||
def __init__(self, embed: Embed) -> None:
|
||||
|
||||
Reference in New Issue
Block a user