title: Check if user is in a voice channel discord.py
body: <p>I am making a bot that will play sounds in a vc. I have made the code to join the call, play the mp3, then leave the call but when the user is not in a call I get this error:</p>
  <pre><code>Ignoring exception in command ring:
  Traceback (most recent call last):
    File &quot;C:\Users\max\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py&quot;, line 85, in wrapped
      ret = await coro(*args, **kwargs)
    File &quot;C:\Users\max\OneDrive\Desktop\Code\DiscordBots\Nokia\Nokia.py&quot;, line 91, in ring
      channel = ctx.author.voice.channel
  AttributeError: 'NoneType' object has no attribute 'channel'
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;C:\Users\max\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\bot.py&quot;, line 903, in invoke
      await ctx.command.invoke(ctx)
    File &quot;C:\Users\max\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py&quot;, line 859, in invoke
      await injected(*ctx.args, **ctx.kwargs)
    File &quot;C:\Users\max\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py&quot;, line 94, in wrapped
      raise CommandInvokeError(exc) from exc
  discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
  </code></pre>
  <p>This is my code that I have so far:</p>
  <pre class="lang-py prettyprint-override"><code>@client.command()
  async def ring(ctx):
      channel = ctx.author.voice.channel
      vc = await channel.connect()
      vc.play(discord.FFmpegPCMAudio(&quot;Audio/NokiaRingtone.mp3&quot;))
      time.sleep(5)
      await ctx.voice_client.disconnect()
  </code></pre>
  <p>If anyone could help me check if the user is in a voice channel that would be great.</p>