Code in question:
bot = commands.Bot(command_prefix='!')
@bot.command(pass_context=True)
async def yt(ctx, url):
author = ctx.message.author
voice_channel = author.voice.channel
vc = await bot.join_voice_channel(voice_channel)
player = await vc.create_ytdl_player(url, before_options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5")
player.start()
Error I receive:
Traceback (most recent call last):
File "/home/wilkins30/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "OverBot.py", line 286, in one
vc = await bot.join_voice_channel(voice_channel)
AttributeError: 'Bot' object has no attribute 'join_voice_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/wilkins30/.local/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
await ctx.command.invoke(ctx)
File "/home/wilkins30/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 727, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/wilkins30/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception:
AttributeError: 'Bot' object has no attribute 'join_voice_channel'
I am running python3 in Ubuntu 19 on a google virtual machine. So I have looked all over and could only find this thread talking about the issue but solutions there didn't work. This worked for me in a windows environment. which lead me to believe it was opus not being loaded so I reinstalled that and verified that it was being successfully called. I have also created a fresh instance of the virtual machine to no avail as well. I'm sort of lost at the moment.
The newer versions of
discord.py
, referred to as therewrite
branch, no longer hasclient.join_voice_channel()
. This has been changed toVoiceChannel.connect
. See documentation here.As there are many changes in the new version, you may have to spend some time to migrate your code. If you would like to install the older version of
discord.py
, referred to as theasync
branch, then you can do so by running the following command on your linux machine.