from io import BytesIO
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=FZ1mj9IaczQ')
audio_stream = yt.streams.filter(only_audio=True)[0]
buffer = BytesIO()
audio_stream.stream_to_buffer(buffer)
buffer.seek(0)
@bot.command()
async def grole(ctx):
import io
username = ctx.author
channel = bot.get_channel(id=111111111111111111)
for attach in ctx.message.attachments:
imgn = attach.filename
img = io.BytesIO(await attach.read())
await channel.send(file = discord.File(img, imgn))