title: Selfmade Discord Bot not working/ AttributeError: 'VoiceState' object has no attribute 'voice'
body: <p>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; ### BOT TOKEN HIDDEN IN POST &quot;)
  </code></pre>
  <p>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;No one is here... &gt; :) &quot;)
          voice_channel = ctx.author.voice.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_options':
              '-reconnect 1 -reconnect_streammed 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 // PAUSED // PAUSED&quot;)
  
      @commands.command()
      async def resume(self, ctx):
          await ctx.voice_client.resume()
          await ctx.send(&quot;RESUME // RESUME // RESUME&quot;)
  
  
  def setup(client):
      client.add_cog(music(client))
  </code></pre>