Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- client = commands.Bot(command_prefix = '!')
- @client.command(aliases=['p'])
- async def play(ctx, url):
- YDL_OPTIONS = {'format': 'bestaudio/best', 'noplaylist':'True'}
- FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
- voice = get(client.voice_clients, guild=ctx.guild)
- with YoutubeDL(YDL_OPTIONS) as ydl:
- info = ydl.extract_info(url, download=False)
- I_URL = info['formats'][0]['url']
- source = await discord.FFmpegOpusAudio.from_probe(I_URL, **FFMPEG_OPTIONS)
- voice.play(source)
- voice.is_playing()
Add Comment
Please, Sign In to add comment