Xtreme_Killer

Discord py Code

May 10th, 2021 (edited)
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3.  
  4. client = commands.Bot(command_prefix = '!')
  5.  
  6. @client.command(aliases=['p'])
  7. async def play(ctx, url):
  8.     YDL_OPTIONS = {'format': 'bestaudio/best', 'noplaylist':'True'}
  9.  
  10.     FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
  11.     voice = get(client.voice_clients, guild=ctx.guild)
  12.     with YoutubeDL(YDL_OPTIONS) as ydl:
  13.           info = ydl.extract_info(url, download=False)
  14.           I_URL = info['formats'][0]['url']
  15.           source = await discord.FFmpegOpusAudio.from_probe(I_URL, **FFMPEG_OPTIONS)
  16.           voice.play(source)
  17.           voice.is_playing()
  18.  
Add Comment
Please, Sign In to add comment