Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.73k stars 3.74k forks source link

'Bot' object has no attribute 'join_voice_channel' #5990

Closed OwOchle closed 3 years ago

OwOchle commented 3 years ago

(Sorry if there is/are some mistakes, i'm french) I want to make a music bot but each time i try to use the function await client.join_voice_channel(voice_channel) it returns that :

Ignoring exception in command test:
Traceback (most recent call last):
  File "F:\Python\Bot Discord\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "F:/Python/Bot Discord/SoundBot.py", line 20, in test
    await client.join_voice_channel(771863365563449364)
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 "F:\Python\Bot Discord\venv\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "F:\Python\Bot Discord\venv\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "F:\Python\Bot Discord\venv\lib\site-packages\discord\ext\commands\core.py", line 94, 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 think my problem is the same as in the issue #1130 but i'm not sure. Here is my code :

from discord import *
from discord.ext import commands
from discord.ext.commands import Bot
from discord.voice_client import VoiceClient
from ffmpeg import *
from asyncio import *

TOKEN = 'it's my token so i removed it'

description = "A soundboard bot"

client = commands.Bot(command_prefix='!', description=description)

@client.event
async def on_ready():
    print("Bot Online")

@client.command()
async def test(ctx):
    voice_channel = 771863365563449364
    await client.join_voice_channel(voice_channel)
client.run(TOKEN)

I hope someone will find my problem. Have a nice day

Rapptz commented 3 years ago

Your code is using an old version of the library, 0.16.12, which is unsupported. In order to receive support, it would be a good idea to migrate to the newest version. If you need help migrating, visit the migration guide: https://discordpy.readthedocs.io/en/latest/migrating.html

If you need more help consider joining the official Discord server. Please do not open more issues regarding migration or the old version. Thank you.