📅  最后修改于: 2022-03-11 14:47:21.752000             🧑  作者: Mango
import discord
from discord.ext import commands
import youtube_dl
client = commands.Bot(command_prefix = '!', intents=intents)
@client.command(pass_context = True)
async def download(ctx, url:str):
ydl_opts = {
'format': 'bestaudio/best',
'preferredcodec': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'webm',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
client.run(TOKEN)