我又回到了书库,被禁止提问,因为它们显然很糟糕,但我需要一些帮助,我已经做了很多研究,但找不到答案;
\n我需要能够使用discord.py Rewrite 将 youtube 直播的音频流式传输到 VC 中以播放广播音乐。我一直在查看 Youtube_DL 和/或 FFMpeg 相关的互联网帖子,所有帖子要么已经过时(discord.py==0.16.x),要么涉及下载 YouTube 视频(无法通过持续的流来执行此操作)。
\n我还尝试查看discord.py v0.16.12 voice_client.pycreate_ytdl_player。但无济于事,我找不到任何解决方案。
这是我的代码目前的情况。这是我的一个齿轮中的一项后台任务。
\n @loop(seconds=5)\n async def check_voice(self):\n try:\n channel = await self.bot.fetch_channel(819346920082112532)\n except NotFound:\n print("[IR] `Infinite Lofi` voice channel not found. Stopping check_voice loop.")\n self.check_voice.cancel()\n return\n\n try:\n infinite_lofi = await channel.connect(timeout=2, reconnect=True)\n except ClientException:\n return\n else:\n print("[IR] Connected to voice channel. Loading from config livestream URL...")\n channel = await self.bot.fetch_channel(780849795572826213)\n message = await channel.fetch_message(780859270010503188)\n ctx = await self.bot.get_context(message)\n\n # …Run Code Online (Sandbox Code Playgroud) 您好,所以我已经尝试解决这个问题几个小时了,但无法弄清楚出了什么问题,我之前在 discord python 中进行了 api 调用,但这是第一次使用这样的多个变量。
@client.command()
async def random(ctx):
url = ('https://randomuser.me/api/')
response = requests.get(url)
title = response.json()["title"]
first = response.json()["first"]
last = response.json()["last"]
number = response.json()["number"]
street = response.json()["name"]
city = response.json()["city"]
state = response.json()["state"]
postcode = response.json()["postcode"]
country = response.json()["country"]
phone = response.json()["phone"]
age = response.json()["age"]
dob = response.json()["date"]
gender = response.json()["gender"]
username = response.json()["username"]
password = response.json()["password"]
image = response.json()['large']
embed = discord.Embed(title="Random Generator", description="**Name:** f'{title}, {first} {last}\n**Address:** {number} {street}, {city}, {state}, {postcode}, {country}\n**Phone:** {phone}\n**Age:** {age}, …Run Code Online (Sandbox Code Playgroud)