Untitled
unknown
plain_text
2 years ago
1.4 kB
2
Indexable
import discord import os from Comp.Ids import CMusic from discord.ext import commands import yt_dlp Id = os.environ['Id'] async def music(ctx, url: str, bot): print("downloading") # Muestra una rueda de carga mientras se descarga la música loading_message = await ctx.response.send_message('Cargando...') # Descarga la música utilizando yt-dlp ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'song', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192' }], 'quiet': True, 'no_warnings': True } #solo con $ #await ctx.message.delete() with yt_dlp.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) # Sube el archivo a un canal específico channel = bot.get_channel(CMusic) await ctx.edit_original_response(content='Subiendo...') await channel.send(file=discord.File('song.mp3')) await ctx.delete_messages() async def play(ctx, url, bot): voice_channel = bot.get_channel(1085953141276676169) await voice_channel.connect() with yt_dlp.YoutubeDL({'format': 'bestaudio'}) as ydl: info = ydl.extract_info(url, download=False) URL = info['formats'][0]['url'] voice_client = ctx.guild.voice_client voice_client.play(discord.FFmpegPCMAudio(URL))
Editor is loading...