播放音频时出现问题-discord.py

时间:2020-05-14 18:13:50

标签: python discord discord.py

好,所以我将其添加到了我的机器人中:

if message.content.startswith('!test'):
    voice = await client.join_voice_channel(message.author.voice.voice_channel)
    args = message.content.split(" ")
    betterargs = " ".join(args[1:])
    player = await voice.create_ytdl_player('https://www.youtube.com/watch?v=' + betterargs)
    player.start()

但是当我输入!test并且聊天中有youtube链接的结尾时,机器人会加入该频道,但这会给我这个错误

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\server\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "noob.py", line 99, in on_message
    voice = await client.join_voice_channel(message.author.voice.voice_channel)
  File "C:\Users\server\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 3211, in join_voice_channel

有人知道怎么回事吗?

1 个答案:

答案 0 :(得分:0)

该属性(create_ytdl_player)在discord.py的重写版本(1.x)中已被删除。请检查discord.py github存储库中的示例以获取更多信息。 (它有一个使用youtube-dl的音乐机器人示例)