question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

join_voice_channel() not working

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Gorialiscommented, Oct 29, 2017
  1. You don’t need both async def and @asyncio.coroutine, if you are using >3.4 you can use either (with async def being preferred, see here.)
  2. 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 a discord.Client. You don’t need to use both of them. You should remove your client and instead use bot for all of the client calls, In your instance:

- await client.join_voice_channel(voice_channel)
+ await bot.join_voice_channel(voice_channel)

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.

0reactions
francescolfcommented, Oct 29, 2017

Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

joinVoiceChannel is not defined - Stack Overflow
You must have made a mistake at joinVoiceChannel({ channelId: message.guild.id, guildId: message.member.voice.
Read more >
[Discord.js] Can't join voice channel, no errors - Reddit
[Discord.js] Can't join voice channel, no errors. Hello, trying to get my bot to join the voice ... Welcome messages with embeds problem....
Read more >
Voice Connections | discord.js Guide
If you try to call joinVoiceChannel on another channel in the same guild in which there is already an active voice connection, the...
Read more >
Cant use voiceChannel.join() · Issue #711 · discordjs/discord.js
voiceChannel is not a thing. As the error says, it's undefined. Imagine being on 50 guilds, how would it know what voiceChannel to...
Read more >
Joining Voice Channels - Discord.js v14 - YouTube
Support the Channel:Become a Member: https://www.youtube.com/ansonthedeveloper/joinBecome a Patreon: http://patreon.com/stuyyBuy me a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found