本文介绍了python'NoneType'对象中的音乐不一致机器人错误,没有属性'create_ytdl_player'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当我运行此代码时:
@client.command(pass_context=True)
async def ranjaplay(ctx, url):
server = ctx.message.server
voice_client = client.voice_client_in(server)
player = await voice_client.create_ytdl_player(url)
players[server.id] = player
player.start()
它返回此错误:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'create_ytdl_player'
请帮助我解决此问题
推荐答案
该错误告诉我们 client
为None.为什么?让我们看一下文档:
the error tells us that client
is None. why? let's look at the docs:
返回与服务器关联的语音客户端.如果找不到语音客户端,则返回None.
Returns the voice client associated with a server.If no voice client is found then None is returned.
简要检查一下cocs,我假设您必须先创建voiceclient(如果尚不存在).可以使用 Client.join_voice_channel 完成.a>.
Checking the cocs briefly, i assume you have to create the voiceclient first, if it doesn't exist yet. this can be done with Client.join_voice_channel.
这篇关于python'NoneType'对象中的音乐不一致机器人错误,没有属性'create_ytdl_player'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!