import discord from . import play_utils from discord.ext import commands import logging logger = logging.getLogger(__name__) class Play(commands.Cog): def __init__(self, bot): self.bot = bot @discord.slash_command(name="grajcuj", description="grajcujmy wszyscy!") async def play(self, ctx: discord.ApplicationContext, query: str = discord.Option(str, "co zagrać??", required=True)): await ctx.defer() url, title = await play_utils.PlayUtils(self.bot).get_url(ctx, query) logger.info(f"Found video: {title}") filename = await play_utils.PlayUtils(self.bot).download(ctx, url) logger.info(f"Downloaded file: {filename}") await play_utils.PlayUtils(self.bot).play(ctx, filename, title) @discord.slash_command(name="grajcuj_zkompresowane", description="grajcujmy wszyscy w wysokiej jakosci!") async def play_compressed(self, ctx: discord.ApplicationContext, url: str = discord.Option(str, "co zagrać??", required=True)): await ctx.defer() url, title = await play_utils.PlayUtils(self.bot).get_url(ctx, url) filename = await play_utils.PlayUtils(self.bot).download(ctx, url) filename = await play_utils.PlayUtils(self.bot).compress(ctx, filename) await play_utils.PlayUtils(self.bot).play(ctx, filename, title) def setup(bot): bot.add_cog(Play(bot))