From 791e75cb2beeca45a6edf52b65f7e299e03b5eaf Mon Sep 17 00:00:00 2001 From: SamlonDev Date: Sat, 14 Jun 2025 18:54:02 +0200 Subject: code-style issues --- cogs/ping_commands.py | 60 --------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 cogs/ping_commands.py (limited to 'cogs/ping_commands.py') diff --git a/cogs/ping_commands.py b/cogs/ping_commands.py deleted file mode 100644 index beb9685..0000000 --- a/cogs/ping_commands.py +++ /dev/null @@ -1,60 +0,0 @@ -import discord -from discord.ext import commands -import asyncio -from yt_dlp import VideosSearch - -class PingCommands(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.Cog.command() - async def vc(self, ctx): - # join voice channel - pass - - @commands.slash_command(name="grajcuj", description="grajcuj melodyje") - async def play(self, ctx, *, search: str): - await ctx.defer() - if not (ctx.author.voice and ctx.author.voice.channel): - await ctx.followup.send("nie jesteś w kanale głosowym") - return - channel = ctx.author.voice.channel - if ctx.voice_client is not None: - vc = ctx.voice_client - await vc.move_to(channel) - else: - vc = await channel.connect() - videos_search = VideosSearch(search, limit=1) - result = videos_search.result() - if not result['result']: - await ctx.followup.send("nie znaleziono wideo dla twojego wyszukiwania.", ephemeral=True) - return - video = result['result'][0] - title = video['title'] - url = video['link'] - - # Get direct audio stream URL - proc = await asyncio.create_subprocess_exec( - "yt-dlp", "-f", "bestaudio", "-g", url, - stdout=asyncio.subprocess.PIPE - ) - stdout, _ = await proc.communicate() - stream_url = stdout.decode().strip() - - ffmpeg_options = { - "before_options": "-probesize 32k -analyzeduration 0 -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", - "options": "-vn" - } - audio = discord.FFmpegPCMAudio( - stream_url, - before_options=ffmpeg_options["before_options"], - options=ffmpeg_options["options"] - ) - if not vc.is_playing(): - vc.play(audio) - await ctx.followup.send(f"gra: {title}") - else: - await ctx.followup.send(f"dodano do koleyjki: {title}") - - - -- cgit v1.2.3