file structure

This commit is contained in:
2023-04-28 01:19:18 +02:00
parent 11c95e93f2
commit 71ff713417
24 changed files with 241 additions and 37 deletions

2
cog/__init__.py Normal file
View File

@ -0,0 +1,2 @@
from .misc import Greetings
from .music import Music

26
cog/misc.py Normal file
View File

@ -0,0 +1,26 @@
from discord import Member, Bot, Cog, ApplicationContext
from discord.commands import slash_command
from logging import Logger
from framework.redis import Redis
class Greetings(Cog):
def __init__(self, bot: Bot, logger: Logger, redis: Redis):
self.bot = bot
self.logger = logger
self.redis = redis
@slash_command()
async def redis_set(self, context: ApplicationContext, key: str, value: str):
self.logger.info(f"redis set {value} at {key}")
await self.redis.set(key, value)
await context.respond(f"redis set {value} at {key}")
@slash_command()
async def redis_get(self, context: ApplicationContext, key: str):
self.logger.info(f"redis get {key}")
value = await self.redis.get(key)
await context.respond(f"redis get {key}: {value}")

35
cog/music.py Normal file
View File

@ -0,0 +1,35 @@
from discord import Bot, Cog, ApplicationContext
from discord.commands import slash_command
from entity import Entry
from logging import Logger
from service import QueueManager
from usecase import Sources
class Music(Cog):
def __init__(
self, bot: Bot, logger: Logger, queueManager: QueueManager, sources: Sources
):
self.bot = bot
self.logger = logger
self.queueManager = queueManager
self.sources = sources
@slash_command(name="play")
async def play(self, context: ApplicationContext, query: str):
async with self.queueManager(context.guild_id) as queue:
test = await self.sources.processQuery(query)
queue.add(
Entry(
title="title",
artist="artist",
album="album",
thumbnail="thumb",
link="fdsdfsd",
requesterId=context.author.id,
)
)
await context.respond(str(test))