title: My Discord python music bot gets an error when asked to play
body: <p>I would appreciate the help in narrowing down this issue.</p>
  <p>My Discord Bot will run in my python environment without errors initially. However, when I try and enter a command to stream a song from youtube, I'll get the below error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py&quot;, line 85, in wrapped
      ret = await coro(*args, **kwargs)
    File &quot;/home/runner/DiscordMusicBot/music.py&quot;, line 25, in play
      ctx.voice_client.stop()
  AttributeError: 'NoneType' object has no attribute 'stop'
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py&quot;, line 939, in invoke
      await ctx.command.invoke(ctx)
    File &quot;/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py&quot;, line 863, in invoke
      await injected(*ctx.args, **ctx.kwargs)
    File &quot;/opt/virtualenvs/python3/lib/python3.8/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 'stop'
  </code></pre>
  <p>I believe I have everything setup right as I have followed <a href="https://www.youtube.com/watch?v=jHZlvRr9KxM" rel="nofollow noreferrer">this Youtube creators tutorial</a>.</p>
  <p>Here is my main.py</p>
  <pre><code>import discord
  from discord.ext import commands
  import music
  
  cogs = [music]
  
  client = commands.Bot(command_prefix='?', intents = discord.Intents.all())
  
  for i in range(len(cogs)):
    cogs[i].setup(client)
  
  
  
  client.run(&quot;MY_TOKEN_PLACED_HERE_REMOVED_FOR_OBVIOUS_REASONS&quot;)
  </code></pre>
  <p>Here is my music.py</p>
  <pre><code>import discord
  from discord.ext import commands
  import youtube_dl
  
  class music(commands.Cog):
    def __init__(self, client):
      self.client = client
    
    @commands.command()
    async def join(self,ctx):
      if ctx.author.voice is None:
        await ctx.send(&quot;You're not in a voice channel!&quot;)
      voice_channel = ctx.author.voice.channel
      if ctx.voice_client is None:
        await voice_channel.connect()
      else:
        await ctx.voice_client.move_to(voice_channel)
    
    @commands.command()
    async def disconnect(self,ctx):
      await ctx.voice_client.disconnect()
  
    @commands.command()
    async def play(self,ctx,url):
      ctx.voice_client.stop()
      FFMPEG_OPTIONS = {'before_option': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
      YDL_OPTIONS = {'format': &quot;bestaudio&quot;}
      vc = ctx.voice_client
  
      with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
        url2 = info['formats'][0]['url']
        source = await discord.FFmpegOpusAudio.from_probe(url2,**FFMPEG_OPTIONS)
        vc.play(source)
  
    @commands.command()
    async def pause(self,ctx):
      await ctx.voice_client.pause()
      await ctx.send(&quot;paused &quot;)
  
    @commands.command()
    async def resume(self,ctx):
      await ctx.voice_client.resume()
      await ctx.send(&quot;resume &quot;)
  
  def setup(client):
    client.add_cog(music(client))
  </code></pre>
  <p>The goal is to be able to play songs in my discord channel since Rythm Bot and Groove Bot went down.</p>
  <p>Cheers,</p>