Repository: Pycord-Development/pycord

Issue:
Discord raised "Already connected to a voice channel." after being disconected using right click in discord app
### Summary

Discord raised "Already connected to a voice channel." after being disconected using right click in discord app

### Reproduction Steps

Connect to voice channel, after that disconnect bot using right click.
![image](https://user-images.githubusercontent.com/58747066/154793033-d2cf1326-a487-4260-ab17-5758dcfe5c8b.png)

After try again connecting bot to voice channel and error will be raised.

### Minimal Reproducible Code

```python
async def connect(ctx: ApplicationContext):
    await ctx.author.voice.channel.connect()
```


### Expected Results

Bot connected to voice channel.

### Actual Results

Ignoring exception in command connect:
Traceback (most recent call last):
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\commands\core.py", line 110, in wrapped
    ret = await coro(arg)
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\commands\core.py", line 770, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\Oliver\Documents\python\MusicianByGroli\cogs\music_controller.py", line 33, in connect
    player = await self._connect(interaction, channel)
  File "c:\Users\Oliver\Documents\python\MusicianByGroli\cogs\music_controller.py", line 22, in _connect
    return await channel.connect(cls=wavelink.Player)
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\abc.py", line 1739, in connect
    raise ClientException('Already connected to a voice channel.')
discord.errors.ClientException: Already connected to a voice channel.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\bot.py", line 768, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\commands\core.py", line 306, in invoke
    await injected(ctx)
  File "C:\Users\Oliver\.virtualenvs\MusicianByGroli\lib\site-packages\discord\commands\core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: ClientException: Already connected to a voice channel.

### Intents

all

### System Information

- Python v3.9.2-final
- py-cord v2.0.0-beta
    - py-cord pkg_resources: v2.0.0b4
- aiohttp v3.8.1
- system info: Windows 10 10.0.19041

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:
It is working fine on my end
Python-3.10.0
py-cord==2.0.0b4884+g68e9cf3d
OS: rasbian
ARM v6
Can reproduce on master.

Resolving patch:
diff --git a/discord/state.py b/discord/state.py
--- a/discord/state.py
+++ b/discord/state.py
@@ -1544,12 +1544,6 @@ def parse_voice_state_update(self, data) -> None:
         # self.user is *always* cached when this is called
         self_id = self.user.id  # type: ignore
         if guild is not None:
-            if int(data["user_id"]) == self_id:
-                voice = self._get_voice_client(guild.id)
-                if voice is not None:
-                    coro = voice.on_voice_state_update(data)
-                    asyncio.create_task(logging_coroutine(coro, info="Voice Protocol voice state update handler"))
-
             member, before, after = guild._update_voice_state(data, channel_id)  # type: ignore
             if member is not None:
                 if flags.voice:
@@ -1567,6 +1561,15 @@ def parse_voice_state_update(self, data) -> None:
                     data["user_id"],
                 )
 
+            if int(data["user_id"]) == self_id:
+                voice = self._get_voice_client(guild.id)
+                if voice is not None:
+                    if guild.me.voice is None:
+                        self._remove_voice_client(guild.id)
+                    coro = voice.on_voice_state_update(data)
+                    asyncio.create_task(logging_coroutine(coro, info="Voice Protocol voice state update handler"))
+
+
     def parse_voice_server_update(self, data) -> None:
         try:
             key_id = int(data["guild_id"])


Test patch: