Repository: Pycord-Development/pycord

Issue:
Fetching Discord Invite fails 
### Summary

Fetching Discord Invite fails 

### Reproduction Steps

Simply call the .fetch_invite function. 
Below is the code from the cog.

### Minimal Reproducible Code

```python
@commands.command()
async def invite_info(self, ctx):
    try:
        online = await self.client.fetch_invite("https://discord.gg/...")
        #...
    except Exception as E:
        print(E)
```


### Expected Results

Fetch should be performed correctly - we should be able to continue working on the `invite` variable, e.g. `invite.approximate_presence_count`

### Actual Results
// Replaced private things with `xxx`
```
Traceback (most recent call last):
  File "c:\Users\User\Documents\GitHub\xxx\cogs\Stats.py", line 267, in invite_info
    online = await self.client.fetch_invite("discord.gg/xxx")
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 1386, in fetch_invite
    data = await self.http.get_invite(invite_id, with_counts=with_counts, with_expiration=with_expiration, guild_scheduled_event_id=event_id)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 1450, in get_invite
    'guild_scheduled_event_id': int(guild_scheduled_event_id),
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
```

### Intents

discord.Intents.all()

### System Information
```
- Python v3.9.6-final
- py-cord v2.0.0-alpha
    - py-cord pkg_resources: v2.0.0a4732+g640c73ad
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19044
```
### 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_
Fetching Discord Invite fails 
### Summary

Fetching Discord Invite fails 

### Reproduction Steps

Simply call the .fetch_invite function. 
Below is the code from the cog.

### Minimal Reproducible Code

```python
@commands.command()
async def invite_info(self, ctx):
    try:
        online = await self.client.fetch_invite("https://discord.gg/...")
        #...
    except Exception as E:
        print(E)
```


### Expected Results

Fetch should be performed correctly - we should be able to continue working on the `invite` variable, e.g. `invite.approximate_presence_count`

### Actual Results
// Replaced private things with `xxx`
```
Traceback (most recent call last):
  File "c:\Users\User\Documents\GitHub\xxx\cogs\Stats.py", line 267, in invite_info
    online = await self.client.fetch_invite("discord.gg/xxx")
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 1386, in fetch_invite
    data = await self.http.get_invite(invite_id, with_counts=with_counts, with_expiration=with_expiration, guild_scheduled_event_id=event_id)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 1450, in get_invite
    'guild_scheduled_event_id': int(guild_scheduled_event_id),
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
```

### Intents

discord.Intents.all()

### System Information
```
- Python v3.9.6-final
- py-cord v2.0.0-alpha
    - py-cord pkg_resources: v2.0.0a4732+g640c73ad
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19044
```
### 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:
That's not a full traceback.
> That's not a full traceback.

edited

That's not a full traceback.
> That's not a full traceback.

edited


Resolving patch:
diff --git a/discord/client.py b/discord/client.py
--- a/discord/client.py
+++ b/discord/client.py
@@ -1337,7 +1337,7 @@ async def fetch_stage_instance(self, channel_id: int, /) -> StageInstance:
 
     # Invite management
 
-    async def fetch_invite(self, url: Union[Invite, str], *, with_counts: bool = True, with_expiration: bool = True, event_id: Snowflake = None) -> Invite:
+    async def fetch_invite(self, url: Union[Invite, str], *, with_counts: bool = True, with_expiration: bool = True, event_id: Optional[int] = None) -> Invite:
         """|coro|
 
         Gets an :class:`.Invite` from a discord.gg URL or ID.
@@ -1361,7 +1361,7 @@ async def fetch_invite(self, url: Union[Invite, str], *, with_counts: bool = Tru
             :attr:`.Invite.expires_at` field.
 
             .. versionadded:: 2.0
-        event_id: :class:`int`
+        event_id: Optional[:class:`int`]
             The ID of the scheduled event to be associated with the event.
 
             See :meth:`Invite.set_scheduled_event` for more
diff --git a/discord/http.py b/discord/http.py
--- a/discord/http.py
+++ b/discord/http.py
@@ -1442,14 +1442,16 @@ def create_invite(
         return self.request(r, reason=reason, json=payload)
 
     def get_invite(
-        self, invite_id: str, *, with_counts: bool = True, with_expiration: bool = True, guild_scheduled_event_id: Snowflake = None
+        self, invite_id: str, *, with_counts: bool = True, with_expiration: bool = True, guild_scheduled_event_id: Optional[int] = None
     ) -> Response[invite.Invite]:
         params = {
             'with_counts': int(with_counts),
             'with_expiration': int(with_expiration),
-            'guild_scheduled_event_id': int(guild_scheduled_event_id),
         }
 
+        if guild_scheduled_event_id is not None:
+            params['guild_scheduled_event_id'] = int(guild_scheduled_event_id)
+
         return self.request(Route('GET', '/invites/{invite_id}', invite_id=invite_id), params=params)
 
     def invites_from(self, guild_id: Snowflake) -> Response[List[invite.Invite]]:


Test patch: