join_voice_channel() not working
See original GitHub issueThis should be a command to let the bot join the author’s voice channel:
@asyncio.coroutine @bot.command(pass_context=True) async def sfx(ctx): voice_channel = ctx.message.author.voice.voice_channel await client.join_voice_channel(voice_channel) print(“Joined channel” + str(voice_channel))
The error is similar to this one: https://github.com/Rapptz/discord.py/issues/814
` Ignoring exception in command sfx 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 244, in sfx vc = await client.join_voice_channel(voice_channel) File “/usr/local/lib/python3.5/site-packages/discord/client.py”, line 3187, 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 846, in process_commands yield from command.invoke(ctx) File “/usr/local/lib/python3.5/site-packages/discord/ext/commands/core.py”, line 374, 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’ `
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
async def
and@asyncio.coroutine
, if you are using >3.4 you can use either (withasync def
being preferred, see here.)client.ws
should only be None before the bot logs in. From your code, it looks like you are using multiple Clients at once, with only one of them being logged in.For reference, every
commands.Bot
is also adiscord.Client
. You don’t need to use both of them. You should remove yourclient
and instead usebot
for all of the client calls, In your instance:Remember that this applies for all references that include a Client, so you may need to amend other code around your bot to follow this as well.
Thank you very much!