mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 19:57:48 +00:00
Added sources functionality + pre-commit
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
|
||||
|
||||
|
||||
|
||||
@@ -33,3 +33,25 @@ class Playlist:
|
||||
@staticmethod
|
||||
async def random(redis: Redis, amount: Optional[int] = 1) -> List[str]:
|
||||
return await redis.srandmember(f"{redis_prefix}:playlist", amount)
|
||||
|
||||
@staticmethod
|
||||
async def add_bulk(redis: Redis, urls: list[str]):
|
||||
await redis.sadd(f"{redis_prefix}:playlist", *urls)
|
||||
|
||||
@staticmethod
|
||||
async def clear(redis: Redis):
|
||||
await redis.delete(f"{redis_prefix}:playlist")
|
||||
|
||||
|
||||
class PlaylistSource:
|
||||
@staticmethod
|
||||
async def get_all(redis: Redis) -> list[str]:
|
||||
return await redis.smembers(f"{redis_prefix}:sources")
|
||||
|
||||
@staticmethod
|
||||
async def add(redis: Redis, source_url: str):
|
||||
await redis.sadd(f"{redis_prefix}:sources", source_url)
|
||||
|
||||
@staticmethod
|
||||
async def remove(redis: Redis, source_url: str) -> bool:
|
||||
return await redis.srem(f"{redis_prefix}:sources", source_url)
|
||||
|
||||
+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