2
votes

When I try to let my bot join my voice channel, I get this error:

await client.join_voice_channel(voice_channel) (line that generates the error)

Traceback (most recent call last):
   File "/usr/local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 50, in wrapped
 ret = yield from coro(*args, **kwargs)
 File "bot.py", line 215, in sfx
vc = await client.join_voice_channel(voice_channel)
File "/usr/local/lib/python3.5/site-packages/discord/client.py", line 3176, in join_voice_channel
session_id_future = self.ws.wait_for('VOICE_STATE_UPDATE', session_id_found)
AttributeError: 'NoneType' object has no attribute 'wait_for'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "/usr/local/lib/python3.5/site-packages/discord/ext/commands/bot.py", line 848, in process_commands
yield from command.invoke(ctx)
 File "/usr/local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 369, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
 File "/usr/local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'wait_for'

I'm getting this error with channel name and channel ID

Function:

description = "Bot"
bot_prefix = "!"

client = discord.Client()
bot = commands.Bot(description=description, command_prefix=bot_prefix)

@bot.command(pass_context=True)
async def join(ctx):
   author = ctx.message.author
   voice_channel = author.voice_channel
   vc = await client.join_voice_channel(voice_channel)
3
self.ws is None. No idea how to fix it, you haven't given a repeatable example.roganjosh
I posted the functionFrancesco
Can we see more of your code?foxyblue
Posted everything. (except the onready() event). I tried to load the opus files but it didn't change anything @GiantsLoveDeathMetalFrancesco

3 Answers

1
votes

This is the code i use to make it work.

#Bot.py
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from discord.voice_client import VoiceClient
import asyncio

bot = commands.Bot(command_prefix="|")

async def on_ready():
    print ("Ready")

@bot.command(pass_context=True)
async def join(ctx):
    author = ctx.message.author
    channel = author.voice_channel
    await bot.join_voice_channel(channel)

bot.run("token")
0
votes

Get rid of the

from discord.voice_client import VoiceClient line and it shoudl be ok.

-1
votes

Try this

await bot.join_voice_channel(channel)