I
I
Igor Gafarchik2020-05-09 23:27:56
Python
Igor Gafarchik, 2020-05-09 23:27:56

Discord.py bot join_voice_channel?

Good day!
ran into a problem writing a discord bot. You need to add a bot to the voice chat.
tried like this:

import discord
from discord import utils
from discord.utils import get
from discord.ext import commands
from discord.ext.commands import Bot
from discord.voice_client import VoiceClient
@bot.event
async def on_ready():
  print ('Bot is ready.')
@bot.command(pass_context=True)
async def play(ctx):
    await bot.join_voice_channel(705816316598026330)

The bot gives the following error:
Traceback (most recent call last):
  File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 92, 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'

How to add it correctly?
I'm a beginner, don't judge strictly)
Thank you in advance)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Gafarchik, 2020-05-10
@Gafarchik

understood all the error)
now for those who are faced with the same as me:
pip install -U discord.py[voice]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question