When calling vc = await bot.join_voice_channel(voice_channel) I get an AttributeError:
AttributeError: 'Bot' object has no attribute 'join_voice_channel'
The code I have is:
import discord
from discord.ext import commands
from discord.voice_client import VoiceClient
import asyncio
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)
player.start()
bot.run('token')
No repro.
Try reinstalling the library:
pip install -U discord.py[voice]
No luck.
There should be no instances where this is reasonably possible with this library (unless you're on some ancient version without voice support?)
Try reinstalling again with no cache (and ensure you're using the right pip):
pip install --no-cache-dir -U discord.py[voice]
If this doesn't work, there's not much more I can do to help you.
Ok, after reinstalling it like that it worked. Thanks!
@mikicat help me have a problem
the song doesnt play what can i do
@filegeiasou Please don't necrobump issues.
For help with using the library, you should join either the official discord.py server or the Discord API server, as the README also links.
@client.command(pass_content=True)
async def connect (ctx):
channel = ctx.message.author.VoiceChannel
await client.VoiceChannel.connect(channel)<
and i get this error
Traceback (most recent call last):
File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 859, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 725, in invoke
await injected(ctx.args, *ctx.kwargs)
File "/home/runner/.local/lib/python3.6/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: 'Member' object has no attribute 'VoiceChannel'