title: Discord.py | Error with the voice channel
body: <p>The purpose of this code is that when a participant joins a certain voice channel, his personal voice channel is created. And when the voice channel remains empty, it is automatically deleted. The code performs its task perfectly, but I get an error in the console. How can I solve this?</p>
  <p>Code:</p>
  <pre><code>@Bot.event
  async def on_voice_state_update(member,before,after):
      if after.channel.id == 826351221145206855:
          for guild in Bot.guilds:
              maincategory = discord.utils.get(guild.categories, id=816323445213626368)
              channel2 = await guild.create_voice_channel(name=f'HALL {member.display_name}',category = maincategory)
              await channel2.set_permissions(member,connect=True,mute_members=True,move_members=True,manage_channels=True)
              await member.move_to(channel2)
              def check(x, y, z):
                  return len(channel2.members) == 0
              await Bot.wait_for('voice_state_update', check=check)
              await channel2.delete()
  </code></pre>
  <p>Error in the console:</p>
  <pre><code>Ignoring exception in on_voice_state_update
  Traceback (most recent call last):
    File &quot;C:\Users\Маки\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py&quot;, line 343, in _run_event
      await coro(*args, **kwargs)
    File &quot;d:\import discord.py&quot;, line 242, in on_voice_state_update
      if after.channel.id == 826351221145206855:
  AttributeError: 'NoneType' object has no attribute 'id'
  </code></pre>